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
What is hot backup and logical backup?
How to create a new table in your schema?
How much memory your 10g xe server is using?
What is instant client oracle?
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....
What are the differences between date and timestamp in oracle?
How to revoke create session privilege from a user in oracle?
Explain what are the advantages of views?
Explain oracle left join with an example?
Can a formula column be obtained through a select statement ?
What are the uses of a database trigger?
Explain an extent?
How do I decide when to use right joins/left joins or inner joins or how to determine which table is on which side?
What privilege is needed for a user to create tables in oracle?
How to delete an existing row from a table in oracle?