The Aim
For each person in the following table, return their star sign.
Example Data
Assumptions
We'll assume that the dates for each zodiac do not change from year to year and that they always fall between these dates:
[tt]
Aries Mar 21–Apr 20
Taurus Apr 21–May 20
Gemini May 21–Jun 20
Cancer Jun 21–Jul 21
Leo Jul 22–Aug 21
Virgo Aug 22–Sep 21
Libra Sep 22–Oct 22
Scorpio Oct 23–Nov 21
Sagittarius Nov 22–Dec 20
Capricorn Dec 21–Jan 19
Aquarius Jan 20–Feb 18
Pisces Feb 19–Mar 20
[/tt]
The Rules
I must be able to use your query and get the full list of people back with their zodiac sign. I must also be able to add new people to this table and get their sign returned. You can use any method you want and it doesn't matter if it will only run in the latest version of SQL Server.
The Winner
The shortest code wins...
____________________________________________________________
Mark,
[URL unfurl="true"]http://aspnetlibrary.com[/url]
Need help finding an answer? Try the Search Facility or read FAQ222-2244.
For each person in the following table, return their star sign.
Example Data
Code:
DECLARE @PEOPLE TABLE (id int IDENTITY(1,1), Name varchar(20), DOB datetime )
INSERT @PEOPLE VALUES ('Joe', '20060101')
INSERT @PEOPLE VALUES ('Fred', '20060201')
INSERT @PEOPLE VALUES ('John', '20060301')
INSERT @PEOPLE VALUES ('Paul', '20060401')
INSERT @PEOPLE VALUES ('Harold', '20060501')
INSERT @PEOPLE VALUES ('Mark', '20060601')
INSERT @PEOPLE VALUES ('Simon', '20060701')
INSERT @PEOPLE VALUES ('Peter', '20060801')
INSERT @PEOPLE VALUES ('David', '20060901')
INSERT @PEOPLE VALUES ('Matthew', '20061001')
INSERT @PEOPLE VALUES ('Andrew', '20061101')
INSERT @PEOPLE VALUES ('Graham', '20061201')
Assumptions
We'll assume that the dates for each zodiac do not change from year to year and that they always fall between these dates:
[tt]
Aries Mar 21–Apr 20
Taurus Apr 21–May 20
Gemini May 21–Jun 20
Cancer Jun 21–Jul 21
Leo Jul 22–Aug 21
Virgo Aug 22–Sep 21
Libra Sep 22–Oct 22
Scorpio Oct 23–Nov 21
Sagittarius Nov 22–Dec 20
Capricorn Dec 21–Jan 19
Aquarius Jan 20–Feb 18
Pisces Feb 19–Mar 20
[/tt]
The Rules
I must be able to use your query and get the full list of people back with their zodiac sign. I must also be able to add new people to this table and get their sign returned. You can use any method you want and it doesn't matter if it will only run in the latest version of SQL Server.
The Winner
The shortest code wins...
____________________________________________________________
Mark,
[URL unfurl="true"]http://aspnetlibrary.com[/url]
Need help finding an answer? Try the Search Facility or read FAQ222-2244.