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

List out the types of joins.

591


Provide an example of a shell script which logs into SQLPLUS as SYS, determines the current date, changes the date format to include minutes & seconds, issues a drop table command, displays the date again, and finally exits.

1572


How to write text literals in oracle?

606


Explain the importance of .pll extension in oracle?

551


How to list all user accounts in oracle?

608






What is open database communication (odbc) in oracle?

544


How we can able to import our own template (users designed MS-Word templates) which has many tabular columns; need to pass some values generate by Oracle-reports9i? Actually need to import more than 400 MS-Word templates into Oracle Reports-9i to minimize layout design in Reports.

1610


What are a collation and state the different types of collation sensitivity?

549


How to grant create session privilege to a user in oracle?

568


normally database take to refresh time 2 hours. but client asked iwant to refresh with in 5 min that same database. do you have any option in BO and Oracle? explain me briefly...kavi

1736


what are archived logs?

1712


What is transport network substrate (tns) in oracle?

585


What is catalog in Oracle?

647


Explain about functional dependency and its relation with table design?

550


how the Oracle Prepares the Execution Plan and how it chooses the Optimal one?

1823