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?
Answers were Sorted based on User's Feedback
Answer / 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 |
Answer / jas
yes its possible...u can use the date functions
select * from table_name where col_name
between add_months (trunc(sysdate,'MONTH')-3)
and trunc(sysdate,'MONTH')-1
try usgin this might help..
| Is This Answer Correct ? | 1 Yes | 2 No |
What is an Integrity Constrains ?
Hi this srilatha. I comlpeted my Oracle-hrms. can u provide me interview questions on Core hr, payroll,sshr,OLM etc..
1) Does oracle have any table which contain all the exceptions and it's code internally?
Compare and contrast between sql and sql server and explain its various functions?
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 is oracle join syntax?
What is sequence?
Why should I use oracle database?
What are internal user account in oracle?
What is Partitions in Table ?
What is null value in oracle?
What is oracle database client?