Recent PostsRecent Posts Popular TopicsPopular Topics
 Home Search Members Calendar Who's On

 T-SQL Query Rate Topic Display Mode Topic Options
Author
 Message
 Posted Tuesday, April 22, 2008 5:48 PM
 Grasshopper Group: General Forum Members Last Login: Saturday, July 19, 2008 3:54 PM Points: 11, Visits: 15
 Well, the question was whether there is another solution. So there might be many, you just have to say, "Yes". As mentioned above, there are plenty, including "union", "negation/and", subquery, I would add CTE, etc. The answer provided is a correct one for this particular case that is rather mensa-oriented. In large scale systems, you would avoid relying on the modulo due to the fact that month list would have to be as generic as possible... As also mentioned above. However, it was fun to answer.
Post #488994
 Posted Wednesday, June 4, 2008 1:53 PM
 Old Hand Group: General Forum Members Last Login: Tuesday, May 26, 2015 12:09 PM Points: 375, Visits: 56
 rbarryyoung (4/16/2008)FYI, it is ALWAYS possible to construct a mathematical expression that will fit ANY finite set of numbers. for instance:` WHERE (month(dob)-2) * (month(dob)-6) * (month(dob)-7) * (month(dob)-8) * (month(dob)-11) * (month(dob)-12) = 0`Works just as well.Fantastic solution....very good one RBarryYoung
Post #511747
 Posted Wednesday, June 4, 2008 2:07 PM
 Old Hand Group: General Forum Members Last Login: Tuesday, May 26, 2015 12:09 PM Points: 375, Visits: 56
 Norma Jean Claeys (4/21/2008)select * from stud_mast join (select 2 choice union select 6 union select 7 union select 8 union select 11 union select 12) choiceswhere month(dob) = choiceI guess there should be ON condition instead of WHERE clause..;)
Post #511757
 Posted Thursday, July 10, 2008 3:05 AM
 SSC Veteran Group: General Forum Members Last Login: Monday, February 8, 2016 9:51 PM Points: 218, Visits: 17
 we can even use charindex(',' + Convert(varchar(2),month(dob)) + ',', ',2,6,7,8,11,12,') >0This won't have impact even if the language is not english MayurArt
Post #531439

 Permissions