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

Answers were Sorted based on User's Feedback



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

Answer / 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

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

Answer / nagaraju

select count(*) from (
select trunc(to_date(sysdate,'DD/MM/rrrr'),'mm') +rownum -1 dates
from dual connect by level <=Add_Months(trunc(to_date(sysdate,'DD/MM/rrrr'),'mm'),1) - trunc(to_date(sysdate,'DD/MM/rrrr'),'mm')
)
where
to_char(dates,'DY')='SAT'

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Oracle General Interview Questions

How to convert characters to numbers in oracle?

0 Answers  


The table has 3 columns 4 rows. The output is which column has least null values( A COL SHOULD BE THE OUTPUT) Write the query plz. A B C ================ 1 NULL 2 NULL 3 4 NULL 5 6 7 NULL NULL O/P C = 2 4 6

2 Answers   TCS,


Can anyone give me information about oracle certification

1 Answers  


how to use select statement as formal parameter in procedure specification?(someone said that using string) ex:-procedure(a in number,select ename from emp ) i am asking syntax like this?

0 Answers   Sierra Atlantica,


Explain view?

0 Answers  






What is oracle and what are its different editions?

0 Answers  


What is oracle instant client?

0 Answers  


What are the uses of Rollback Segment ?

2 Answers  


candidate key is subset of super key but not vice-verse explain

0 Answers  


What is the difference between 10g OEM and 11g OEM?

0 Answers   MCN Solutions,


What is an oracle transaction?

0 Answers  


how table is defined in plsql table? how can i select column from plsql table? can i use select * from plsql table type?

1 Answers  


Categories
  • Oracle General Interview Questions Oracle General (1789)
  • Oracle DBA (Database Administration) Interview Questions Oracle DBA (Database Administration) (261)
  • Oracle Call Interface (OCI) Interview Questions Oracle Call Interface (OCI) (10)
  • Oracle Architecture Interview Questions Oracle Architecture (90)
  • Oracle Security Interview Questions Oracle Security (38)
  • Oracle Forms Reports Interview Questions Oracle Forms Reports (510)
  • Oracle Data Integrator (ODI) Interview Questions Oracle Data Integrator (ODI) (120)
  • Oracle ETL Interview Questions Oracle ETL (15)
  • Oracle RAC Interview Questions Oracle RAC (93)
  • Oracle D2K Interview Questions Oracle D2K (72)
  • Oracle AllOther Interview Questions Oracle AllOther (241)