Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> SQL: Group BY + Order By

SQL: Group BY + Order By

From: Yuzie <tekait11_at_bni.co.id>
Date: Thu, 18 Jan 2001 09:13:07 +0700
Message-Id: <10744.126948@fatcity.com>


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

MAR 566 78678 instead of:
JAN      890    9899
FEB      897    8686
MAR    566    78678
APR      233     86999

AUG 1000 20100 How can I order it correctly? Thank in advance to you all. Received on Wed Jan 17 2001 - 20:13:07 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US