VERY URGENT PLEASE HELP [message #19076] |
Wed, 27 February 2002 09:43 |
Nina
Messages: 113 Registered: March 2000
|
Senior Member |
|
|
Does anyone know how one can perform a count on the returned by decode statement values?
I have the following example of decode:
DECODE(my_value, 'F', 'First Value', 'S', 'Second Value', 'T', 'Third Value').
In the end of the select I need to have the count of ALL these values. So it would look something like:
First Value - 9
Second Value - 8
Third Value - 0
Any ideas whould be great!
Thank you in advance.
|
|
|
Re: VERY URGENT PLEASE HELP [message #19078 is a reply to message #19076] |
Wed, 27 February 2002 10:00 |
Jon
Messages: 483 Registered: May 2001
|
Senior Member |
|
|
14:59:21 ==> select * from table1;
M
-
F
F
F
F
F
F
F
S
S
S
S
T
T
T
T
T
T
17 rows selected.
14:59:28 ==> select decode(myvalue,'F','First','S','Second','T','Third'), count(*)
14:59:33 2 from table1
14:59:33 3 group by decode(myvalue,'F','First','S','Second','T','Third');
DECODE COUNT(*)
------ ---------
First 7
Second 4
Third 6
|
|
|
Re: VERY URGENT PLEASE HELP [message #19080 is a reply to message #19076] |
Wed, 27 February 2002 10:09 |
Jon
Messages: 483 Registered: May 2001
|
Senior Member |
|
|
You're welcome. By the way, this will not put out
Fourth Value - 0
You will know by its not being there that there were zero occurrences found.
|
|
|