Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Mailing Lists -> Oracle-L -> SQL: Group BY + Order By
Dear All,
I need to query columns (with a certain format) and pass the resultset to a
VB object (chart).
Column required are:
1. SUBSTR(TO_CHAR(value_date),4,3) -> will show month name (string), such as
JAN, FEB, MAR, etc and will be used for X axis.
2. COUNT(reference) -> will show total number of transaction within a month
and will be used for Y axis
3. SUM(amount) -> will show total amount of transactions, and will be used
for second Y axis
My query statement is:
SELECT SUBSTR(TO_CHAR(value_date),4,3) AS MONTH, COUNT(reference) AS TRX,
SUM(amount) AS "TOTAL USD VALUE"
WHERE value_date >= '01-jan-2000' AND tglval <= '31-dec-2001'
GROUP BY SUBSTR(TO_CHAR(value_date),4,3).
The problem is it sorts the result alphabetically, so will give: AUG 1000 20100
APR 233 86999 FEB 897 8686 JAN 890 9899
JAN 890 9899 FEB 897 8686 MAR 566 78678 APR 233 86999
![]() |
![]() |