I need to get the values of the previous quarter.how to do
this?eg: if my cuurent month is may i need to get the datas
of the month jan,feb,march.Can it be done in oracle.I tried
with date function q but for the month jan its not
retriving the previous quarter(oct-dec).how to solve
this.plpz anyone help me?

Answer Posted / aseem k

SCOTT.EMP TABLE WITH HIREDATE AS COLUMN :

select hiredate,
decode (mod(to_number(to_char(hiredate,'mm')) ,
3 ),0,add_months(last_day(hiredate)+1,-6),1,add_months
(last_day(hiredate)+1,-4),2,add_months(last_day(hiredate)
+1,-5)) "first day OF PREVIOUS QUARTER",
decode (mod(to_number(to_char(hiredate,'mm')) ,
3 ),0,add_months(last_day(hiredate),-3),1,add_months
(last_day(hiredate),-1),2,add_months(last_day(hiredate),-
2)) "last day OF PREVIOUS QUARTER"
from emp


REGARDS
ASEEM

Is This Answer Correct ?    3 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is hot backup and logical backup?

612


How to create a new table in your schema?

615


How much memory your 10g xe server is using?

586


What is instant client oracle?

548


how do we code triggers , store procedure , Performance tuning and indexing in a Java Project? Pls kindly get me the perfect answer with the code for each....thank you in advance............pls any body kindly help me soon as possible....

1594






What are the differences between date and timestamp in oracle?

556


How to revoke create session privilege from a user in oracle?

561


Explain what are the advantages of views?

615


Explain oracle left join with an example?

592


Can a formula column be obtained through a select statement ?

1849


What are the uses of a database trigger?

525


Explain an extent?

661


How do I decide when to use right joins/left joins or inner joins or how to determine which table is on which side?

550


What privilege is needed for a user to create tables in oracle?

554


How to delete an existing row from a table in oracle?

649