C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !






Oracle Query


Posted Date: 15 Sep 2008    Resource Type: Code Snippets    Category: SQL

Posted By: Prafulla S Shimpi       Member Level: Gold
Rating:     Points: 5



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;




Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Oracle  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: How to find tables with record count
Previous Resource: Making your SQL string synatx friendly
Return to Discussion Resource Index
Post New Resource
Category: SQL


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design

fax server

Contact Us    Privacy Policy    Terms Of Use