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
Can group functions be mixed with non-group selection fields?
What is the effect of setting the value "all_rows" for optimizer_goal parameter of the alter session command? What are the factors that affect optimizer in choosing an optimization approach?
What is the cache hit ratio, what impact does it have on performance of an Oracle database and what is involved in tuning it?
Explain what are the uses of rollback segment?
What is the difference between sharding and replication?
How to assign values to data fields in record variables?
What do you understand by a database object?
How to test null values?
Explain mutating triggers.
What are the major difference between truncate and delete?
Explain what are the characteristics of data files?
Explain index?
What are the built-in functions used for sending Parameters to forms ?
What to do if dba lost the system password?
How to experiment a data lock in oracle?