Language PostgreSQL
(Pure SQL syntax version)
| Date: | 04/11/07 |
| Author: | gusC |
| URL: | n/a |
| Comments: | 0 |
| Info: | http://www.postgresql.org/ |
| Score: |
SELECT
CASE (bottlecount)
WHEN 0 THEN 'No more bottle of beer on the wall,\n no more bottles of beer.\n ' ||
'Go to the store and buy some more,\n 99 bottles of beer on the wall.\n'
WHEN 1 THEN '1 bottle of beer on the wall,\n 1 bottle of beer.\n ' ||
'Take one down and pass it around,\n no more bottles of beer on the wall.\n'
WHEN 2 THEN '2 bottles of beer on the wall,\n 2 bottles of beer.\n ' ||
'Take one down and pass it around,\n 1 bottle of beer on the wall.\n'
ELSE
rtrim (cast((BottleCount) as char(2))) || ' bottles of beer on the wall,\n ' ||
rtrim (cast((BottleCount) as char(2))) || ' bottles of beer.\n ' ||
'Take one down and pass it around,\n ' ||
rtrim (cast((BottleCount)-1 as char(2))) || ' bottles of beer on the wall.\n'
END
FROM
(
SELECT avalue * 10 + bvalue AS bottlecount
FROM generate_series(9,0,-1) AS avalue, generate_series(9,0,-1) AS bvalue
) as valuelist;
Download Source | Write Comment
Download Source | Write Comment
Add Comment
Please provide a value for the fields Name,
Comment and Security Code.
This is a gravatar-friendly website.
E-mail addresses will never be shown.
Enter your e-mail address to use your gravatar.
Please don't post large portions of code here! Use the form to submit new examples or updates instead!
Comments