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

Home -> Community -> Usenet -> c.d.o.misc -> Re: SQL sentence

Re: SQL sentence

From: Mark D Powell <Mark.Powell_at_eds.com>
Date: 21 Jul 2005 07:04:02 -0700
Message-ID: <1121954641.829079.103470@o13g2000cwo.googlegroups.com>


Noriepa,

You can use a group by to get a count(*) for each existing code per city

UT1 > select * from citycode;

C CO
- --
A XX
B SS
A ZZ
C YY
D XX
B SS
B ZZ

7 rows selected.

UT1 > select city, code, count(*) from citycode group by city, code;

C CO COUNT(*)
--- ----- -----

A XX          1
A ZZ          1
B SS         2
B ZZ          1
C YY         1
D XX          1

6 rows selected.

You can then pivot this data (by feeding this query result into a join with the pivot table). You can find information on pivot tables in the newsgroup archives and/or at the asktom.oracle.com website.

HTH -- Mark D Powell -- Received on Thu Jul 21 2005 - 09:04:02 CDT

Original text of this message

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