SELECT DECODE (SIGN (TO_NUMBER (SUBSTR (month_code, 5)) - 6),
1, SUBSTR (month_code, 1, 4)
|| '-'
|| TO_CHAR (TO_NUMBER (SUBSTR (month_code, 1, 4)) + 1),
TO_CHAR (TO_NUMBER (SUBSTR (month_code, 1, 4)) - 1)
|| '-'
|| SUBSTR (month_code, 1, 4)
) fin_year,
SUM (bill_amt) bill_amt
FROM emp_bill
GROUP BY DECODE (SIGN (TO_NUMBER (SUBSTR (month_code, 5)) - 6),
1, SUBSTR (month_code, 1, 4)
|| '-'
|| TO_CHAR (TO_NUMBER (SUBSTR (month_code, 1, 4)) + 1),
TO_CHAR (TO_NUMBER (SUBSTR (month_code, 1, 4)) - 1)
|| '-'
|| SUBSTR (month_code, 1, 4)
)
SELECT TO_CHAR (ADD_MONTHS (TO_DATE (month_code, 'rrrrmm'), -6),
'RRRR'
)
|| '-'
|| TO_CHAR (ADD_MONTHS (TO_DATE (month_code, 'rrrrmm'), 6), 'RRRR')
fin_yr,
SUM (bill_amt) bill_amt
FROM emp_bill
GROUP BY TO_CHAR (ADD_MONTHS (TO_DATE (month_code, 'rrrrmm'), -6), 'RRRR')
|| '-'
|| TO_CHAR (ADD_MONTHS (TO_DATE (month_code, 'rrrrmm'), 6), 'RRRR')
select add_months(last_day(sysdate),-1)+1 from dual
select to_date(to_char(sysdate,'RRRRMM'),'RRRRMM') from dual
select trunc(sysdate,'MM') from dual
select to_number(to_char(sysdate, 'Dth'))-6 from dual
select substr(month_code,5)-6 from emp_bill
Halim, a Georgia Tech graduate Senior Database Engineer/Data Architect based in Atlanta, USA, is an Oracle OCP DBA and Developer, Certified Cloud Architect Professional, and OCI Autonomous Database Specialist. With extensive expertise in database design, configuration, tuning, capacity planning, RAC, DG, scripting, Python, APEX, and PL/SQL, he combines technical mastery with a passion for innovation. Notably, Halim secured 16th place worldwide in PL/SQL Challenge Cup Playoff on the year 2010.
Friday, September 11, 2009
Subscribe to:
Post Comments (Atom)
My Blog List
-
-
-
ASSM states3 weeks ago
-
UKOUG Discover 20241 month ago
-
-
-
-
-
-
-
-
Moving Sideways8 years ago
-
-
Upcoming Events...11 years ago
-
No comments:
Post a Comment