leegarson
asked on
IF/ELSIF program in SQL
Chinese Zodiac question:
I have to write an SQL program which I have to find what animal is on my birthyear. I need to declare a date variable birth_date and assign it to my birthdate. Use an IF/ELSIF structure to test every year and determine the animal associated with my birth year.
1924.36.48.60.72.84.96 - Rat
1925.37.49.61.73.85.97 - Cow
1926.38.50.62.74.86.98 - Tiger
1927.39.51.63.75.87.99 - Rabbit
1928.40.52.64.76.88.00 - Dragon
1929.41.53.65.77.89.01 - Snake
...................... - Horse
...................... - Sheep
...................... - Monkey
...................... - Chicken
...................... - Dog
1935.47.59.71.83.95.07 - Pig
output should be this
dbms_output.put_line('I was born in ' || year || ', which is the year of the ???') ??? = whatever animal is in that year.
I have to write an SQL program which I have to find what animal is on my birthyear. I need to declare a date variable birth_date and assign it to my birthdate. Use an IF/ELSIF structure to test every year and determine the animal associated with my birth year.
1924.36.48.60.72.84.96 - Rat
1925.37.49.61.73.85.97 - Cow
1926.38.50.62.74.86.98 - Tiger
1927.39.51.63.75.87.99 - Rabbit
1928.40.52.64.76.88.00 - Dragon
1929.41.53.65.77.89.01 - Snake
...................... - Horse
...................... - Sheep
...................... - Monkey
...................... - Chicken
...................... - Dog
1935.47.59.71.83.95.07 - Pig
output should be this
dbms_output.put_line('I was born in ' || year || ', which is the year of the ???') ??? = whatever animal is in that year.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
By the way, % is the modulo (remainder) operator in SQL Server; on other systems it is MOD or \ or whatever else.