Voting

Category

real language

Bookmarking

Del.icio.us Digg Diigo DZone Earthlink Google Kick.ie
Windows Live LookLater Ma.gnolia Reddit Rojo StumbleUpon Technorati

Language PostgreSQL

(Pure SQL syntax version)

Date:04/11/07
Author:gusC
URL:n/a
Comments:0
Info:http://www.postgresql.org/
Score: (2.71 in 7 votes)
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

Alternative Versions

VersionAuthorDateCommentsRate
1David Eddyshaw04/20/050

Comments

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!

Name:

eMail:

URL:

Security Code:
  
Comment: