Home » SQL & PL/SQL » SQL & PL/SQL » how query write for distint dates
how query write for distint dates [message #7836] Fri, 11 July 2003 05:45 Go to next message
Raja
Messages: 57
Registered: March 2000
Member
I have table there are some date corresponding amount fields

how can i get month name and sum amount regarding that month

Result
Month Name Amount
-----------------
Mar 33434
------------------
Table

paydate amount
------- ------
08-MAR-03 1110
08-MAR-03 1274
09-MAR-03 94
09-MAR-03 104
09-MAR-03 127

01-APR-03 1110
03-APR-03 1274
05-APR-03 94
05-APR-03 104
06-APR-03 127

08-MAY-03 1110
08-MAY-03 1274
09-MAY-03 94
09-MAY-03 104
09-MAY-03 127
Re: how query write for distinct dates [message #7844 is a reply to message #7836] Fri, 11 July 2003 11:30 Go to previous message
Todd Barry
Messages: 4819
Registered: August 2001
Senior Member
select trunc(paydate, 'mm'), sum(amount)
  from t
 group by trunc(paydate, 'mm');


This will convert every date to the first of the month and the group by that value. You would need to display the year as part of the result unless you are filtering the data (where trunc(paydate, 'y') = 2003).
Previous Topic: How to compile or encrypt a SQL query
Next Topic: PostgreSQL
Goto Forum:
  


Current Time: Fri Apr 19 12:07:50 CDT 2024