|
|
|
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.
|
|
|
|
|
Old Hand
      
Group: General Forum Members
Last Login: Monday, May 27, 2013 1:41 AM
Points: 342,
Visits: 53
|
|
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
|
|
|
|
|
Old Hand
      
Group: General Forum Members
Last Login: Monday, May 27, 2013 1:41 AM
Points: 342,
Visits: 53
|
|
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) choices where month(dob) = choice
I guess there should be ON condition instead of WHERE clause..;)
|
|
|
|
|
SSC Veteran
      
Group: General Forum Members
Last Login: Wednesday, June 16, 2010 1:09 AM
Points: 218,
Visits: 15
|
|
we can even use charindex(',' + Convert(varchar(2),month(dob)) + ',', ',2,6,7,8,11,12,') >0
This won't have impact even if the language is not english
MayurArt
|
|
|
|