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 the difference between view and materialized view in Oracle?
What is oracle open database communication (odbc)?
How can I see all tables in oracle?
Why does for update in oracle 8 cause an ora-01002 error?
How to use subqueries with the exists operator in oracle?
How can I create database in oracle?
What is SQL access advisor in Oracle?
What is a nvl function?
How do we get field details of a table?
List the parts of a database trigger.
How do I escape a reserved word in oracle?
How to use subqueries in the from clause in oracle?
What is a procedure in oracle?
Explain a synonym?
Why do we use coalesce function in oracle?