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

How to speed up webrick?

586


How to insert a new row into a table in oracle?

581


How to define an anonymous procedure with variables?

537


Explain the importance of .pll extension in oracle?

547


How to view the data files in the current database?

584






How to write a query with a right outer join in oracle?

609


What is the quickest way to export a table to a flat file?

566


Illustrate how to determine the amount of physical CPUs a Unix Box possesses (LINUX and/or Solaris).

1799


How to pass parameters to procedures in oracle?

566


How to work with data objects interactively?

548


How do I know if oracle is installed on windows?

482


How to convert numbers to characters in oracle?

582


How to define a cusotmer as a supplier in ORACLE R12

1723


what is partitioning? Types of partitioning. explain? what is the new kind of partitioning type introduced in 9i?

1844


Differentiate between post-database commit and post-form commit?

539