Table name: T1, it has only one column.

col1
------
c
b
a
b
b
b
b
d
s
a
a
t
s


Requirement:

I need the following output from the above base table by
using SQL query.


col1 Cnt
----- -------
a 3
b 5
Others 5


Please help.

Thanks
Guru
v.gurus@in.com








Answer Posted / vivek nagarajan

SELECT SUM(DECODE(txt,'a',1)) a_count,
SUM(DECODE(txt,'b',1)) b_count,
SUM(DECODE(txt,'a',0,'b',0,1)) others_count
FROM t1;

Is This Answer Correct ?    2 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the reports view in oracle sql developer?

533


How to run sql functions in pl/sql?

534


Does pdo prevent sql injection?

516


What is index example?

546


Can we debug stored procedure?

513






Does sql support programming?

543


When can we use the where clause and the having clause?

569


What's the procedure?

481


What is program debugging?

552


What are tables and fields?

578


How many commands are in sql?

517


What is sql query limit?

504


how to calculate the difference between two dates? : Sql dba

541


What are the sql versions?

510


what is union? : Sql dba

573