Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
mike1973
Starting Member
46 Posts |
Posted - 2011-01-13 : 03:57:48
|
| HelloPlease can anyone help in writing a query with some if conditions?the query is supposed to select the Top 5 children from a table called childrenwhereIF Child.sex=Male(child.Studying=True AND (Today-Child.BirthDate > 21)) OR Child.Handicap=True OR (Today-Child.Birthdate) > 18thenif Child.Works=False OR Child.Married=FalseelseThanks |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2011-01-13 : 04:28:13
|
[code]WHERE( ( child.sex = 'Male' AND (child.Studying='True' AND DATEDIFF(YEAR,Child.BirthDate,getdate()) > 21) OR Child.Handicap='True' OR DATEDIFF(YEAR,Child.BirthDate,getdate()) > 18 ) AND Child.Works='False' OR Child.Married='False')OR( ...)[/code] No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
|
|
|