Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase ««12

Using Exotic Joins in SQL Part 1 Expand / Collapse
Author
Message
Posted Friday, April 29, 2005 9:51 AM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Monday, April 14, 2014 11:53 AM
Points: 226, Visits: 688

I think you can use the following sql to do your work

select * from My_Table

where col_date between isnull(@Start_Date, '1900-01-01') and isnull(@End_Date, '2999-01-01')

Assume your real date is no earlier than '1900-01-01' and no later than '2999-01-01')




Post #178836
Posted Monday, May 02, 2005 9:26 AM


SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: Monday, March 10, 2014 1:21 PM
Points: 885, Visits: 1,526

David,

You say that dropping the support for the WHERE clause is breaking away from the ANSI standard.  It is the ANSI standard that has pshed the move to using the FROM clause for Joins and not the WHERE clause.  Based on that how would this move by Microsoft be considered a move away from the ANSI standard?  Even if the latest standard allows for joins in the FROM and WHERE clause the fact that the preferred method of joins is in the FROM clause I would think that sticking with usisng the WHERE clause would actually be a move away from the ANSI standard.

PLease understand that I am not trying to sound negative or attack your comment, I know personally how emails and postings are poor at properly conveying emotions.  I am merely trying to understand why you feel this way and try to find out if maybe I have missed something or have improperly understood the ANSI standard.

Thanks

Ed



Kindest Regards,

A Democracy works great until the day you find yourself on the sheep side of a vote between 5 wolves and 4 sheep on what’s for dinner when neither have eaten in many days. A free Republic where the rights of the few and the individual are protected is the only one in which Freedom and Prosperity for all have a chance to blossom.
Post #179224
Posted Monday, May 02, 2005 6:15 PM


Mr or Mrs. 500

Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500

Group: General Forum Members
Last Login: Tuesday, June 21, 2011 10:03 AM
Points: 577, Visits: 102
quote

BETWEEN is purely simpler to read. There is no specific engine enhancements that make BETWEEN any faster.

 

2cents more..."Between" is not ANSI 92 standard, so using < and > is more portable.


Signature is NULL
Post #179363
Posted Wednesday, May 03, 2006 5:23 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Wednesday, December 19, 2012 4:27 PM
Points: 12, Visits: 20

Hi

You can write query like this:

suppose say you are passing two parameters name @StartDate and @EndDate and you column name in table is TransDate

TransDate BETWEEN ISNULL(@StartDate, TransDate) AND ISNULL(@EndDate, TransDate)

 

Rohit

Post #277084
Posted Wednesday, August 29, 2007 9:54 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Wednesday, February 06, 2013 3:04 PM
Points: 38, Visits: 417
One of the poorest articles I have read in the long time. Theta join is by no means an exotic operator. Set equality and set containment join is. Google "relational division"
Post #394806
« Prev Topic | Next Topic »

Add to briefcase ««12

Permissions Expand / Collapse