Write a statement that prints the numbers from 1 to 100. But for multiples of three print "Prafulla" instead of the number and for the multiples of five print "Shimpi". For numbers which are multiples of both three and five print "PrafullaShimpi".
SELECT CASE WHEN MOD (ROWNUM, 15) = 0 THEN 'Prafulla' WHEN MOD (ROWNUM, 3) = 0 THEN 'Shimpi' WHEN MOD (ROWNUM, 5) = 0 THEN 'PrafullaShimpi' ELSE TO_CHAR (ROWNUM) END answer FROM all_tables WHERE ROWNUM <= 100;
2. Other way
SELECT DECODE(mod(rownum,3),0, DECODE(mod(rownum,5),0,'PrafullaShimpi', 'Prafulla'), DECODE(mod(rownum,5),0,'Shimpi',RowNum) ) As Answers from ALL_OBJECTS where rownum < 101;
|
No responses found. Be the first to respond and make money from revenue sharing program.
|