count # of unioned values

From: Joe Powell <joe.powell_at_lmco.com>
Date: 4 Feb 2004 13:57:27 -0800
Message-ID: <deea9325.0402041357.3037f269_at_posting.google.com>


Suppose I have a table with 2 VARCHAR2(1)columns C1 and C2 and the following 3 rows:
A B
A C
B A

For each value in columns C1 and/or C2, I need to report the count of that value in each column such as:

Value #C1s #C2s
----- ----- -----

A         2     1
B         1     1
C         0     1

----- ----- -----
Total 3 3

I have written a PL/SQL procedure to do this. With Oracle 9.2 what is the best method to do this with a single SQL query? Received on Wed Feb 04 2004 - 22:57:27 CET

Original text of this message