How to find no of saturdays in a month using single sql ?

Answer Posted / anuradha

Select Count(*)
From (Select Trunc(To_Date('20120305', 'yyyymmdd'), 'MM')
+ Rownum - 1 Dates
From (Select 1 From Dual Group By Cube(2, 2, 2,
2, 2))
Where Rownum <=
Add_Months(Trunc(To_Date
('20120305', 'YYYYMMDD'), 'MM'), 1) -
Trunc(To_Date('20120305', 'YYYYMMDD'), 'MM'))
Where To_Char(Dates, 'DY') In ('SAT');

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain the use of Merge statement in oracle 11g

598


How can windows applications connect to oracle servers?

524


Explain what are the uses of rollback segment?

590


Describe an oracle table?

577


when we are importing items in inventory, showing errors, Oracle support suggested us for running scripts & also suggested if we run scripts, iprocurement applicaation if is there it will show shared and if we go in future for iprocurement, it wont work. So kinldy suggest any functional solution.

1477






What is an oracle and why it is used?

627


How do I uninstall oracle 11g?

565


i wrote a pl/sql procedure. it must run every sunday 4.40 How can i schedule it with the help of dbms_jobs (or another other procedure with out creating bat file,exe file)

1807


Is there any function in oracle similar like group_concat of mysql?

542


What are the differences between date and timestamp in oracle?

556


What is backup in Oracle?

573


What the is the diff between local index and global index. give some example.

1138


What is a nested table?

633


How to speed up webrick?

601


What is Reduced List of Values?

1708