Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Mailing Lists -> Oracle-L -> Re: group by sorting
On 17 Oct 2000, at 14:22, Bowes, Chris wrote:
Date sent: Tue, 17 Oct 2000 14:22:42 -0800 To: Multiple recipients of list ORACLE-L <ORACLE-L_at_fatcity.com> Send reply to: ORACLE-L_at_fatcity.com From: "Bowes, Chris" <Chris.Bowes_at_kosa.com> Subject: group by sorting
> I have looked in a couple manuals for this but have not found it. When
> doing a group by, a sort is done on the data. Is there anyway to specify a
> descending order for that sort?
It's too easy! Use "order by" after "group by"
The following shows the default in the first query, then results from the use of "order by" in a second query:
spool
currently spooling to C:\WINDOWS\DESKTOP\GROUP.LST
SQL> l
1 select
2 count(*), 3 STU_ETH_CODE 4 from 5 SIS_CSUS_ALL_FALL_2000_CENSUS 6 group by 7* STU_ETH_CODE
COUNT(*) S --------- - 302 1 1628 2 2512 3 463 4 305 5 104 6 12643 7 784 8 231 9 129 A 113 B 950 C 2981 D 1012 F 22 G 31 H 252 J 148 K 110 L 78 M 17 N COUNT(*) S --------- - 85 P 15 Q 403 R 330 S 25 T 794 V 92
28 rows selected.
SQL> ed
Wrote file afiedt.buf
1 select
2 count(*), 3 STU_ETH_CODE 4 from 5 SIS_CSUS_ALL_FALL_2000_CENSUS 6 group by 7 STU_ETH_CODE 8 order by 9* STU_ETH_CODE desc
COUNT(*) S --------- - 92 794 V 25 T 330 S 403 R 15 Q 85 P 17 N 78 M 110 L 148 K 252 J 31 H 22 G 1012 F 2981 D 950 C 113 B 129 A 231 9 784 8 COUNT(*) S --------- - 12643 7 104 6 305 5 463 4 2512 3 1628 2Received on Tue Oct 17 2000 - 23:10:32 CDT
![]() |
![]() |