Write the sql query using dual table for below output?

1 L R
--- --- ----
1 1 1
1 2 1
1 3 1
1 1 2
1 2 2
1 3 2
1 1 3
1 2 3
1 3 3

Write a query using only Dual table with out writing any pl/sql program.

Answer Posted / shailesh

select 1 as "1", decode(mod(level,3), 0, 3, mod(level,3))as l,
case
when level<=3 then 1
when level>3 and level <7 then 2
else
3
end as r
from dual connect by level<10;

Is This Answer Correct ?    5 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How do you explain an index number?

749


Is sql a backend language?

846


Can you load data into multiple tables at once? : aql loader

802


Mention what does plvtab enables you to do when you showthe contents of pl/sql tables?

905


What are analytic functions in sql?

743






How do you update sql?

712


How do I partition a table in sql?

734


How will you distinguish a global variable with a local variable in pl/sql?

844


Can a varchar be a primary key?

699


What is the use of nvl function?

867


What is ttitle and btitle?

768


what is the difference between char_length and length? : Sql dba

790


What is the use of %rowtype?

749


What are the rules to be applied to nulls whilst doing comparisons?

988


How do I truncate a word?

705