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 Oracle 9i SQL

Date:04/20/05
Author:Albert Indeev
URL:n/a
Comments:2
Info:n/a
Score: (3.00 in 37 votes)
 -- SQL (Oracle9i)
-- history from Albert Indeev
-- assa@ykt.ru
-- 29.01.2004 6:00+GMT9
-- tested on Oracle 9.2.0.4
-- used only one table - "dual" :)

select case
when  1 < 100-rownum then
  to_char(100-rownum) || ' bottles of beer on the wall,' || chr(10) ||
  to_char(100-rownum) || ' bottles of beer.' || chr(10) ||
  'Take one down, pass it around,' || chr(10) ||
  to_char( 99-rownum) || ' bottles of beer on the wall.'
when  1 = 100-rownum then
  to_char(100-rownum) || ' bottle of beer on the wall,' || chr(10) ||
  to_char(100-rownum) || ' bottle of beer.' || chr(10) ||
  'Take one down, pass it around,' || chr(10) ||
  'No more beers.'
end history
from (select 1 from dual group by cube (1,1,1,1,1,1,1)) where rownum+28 < 128;

Download Source | Write Comment

Alternative Versions

Comments

>>  Ataman KALKAN said on 08/11/07 16:56:12

Ataman KALKAN This one is the best version of PL/SQL coding.
Note : All the languages(!) below are needed to be stated as "Alternate versions of PL/SQL" :

"Oracle SQL"
"PL/SQL"
"Oracle 9i SQL"
"SQL (Self contained Oracle 9i+ Version)"
"SQL (Produces the exact lyrics, ORACLE)"

>>  Davos said on 01/26/08 13:05:37

Davos Ataman:
There is no PL/SQL here, its pure SQL - for Oracle of course, not sure if any other SQL based DB's use a dummy table called 'Dual'.

Its also compact and extremely clever. Love the group by cube action!

Agree with your other comment about the versions, agreed. Perhaps should just be under heading 'SQL' as there are MySQL and Sybase versions here among others.

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: