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 / vikneswaran

select decode(col1,'a','a','b','b','Other') "col1",count
(col1) "countval"
from col group by col1;

Is This Answer Correct ?    0 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How to get unique records from a table?

523


Does sql*plus also have a pl/sql engine?

563


What is lookup table in sql?

603


how can we transpose a table using sql (changing rows to column or vice-versa) ? : Sql dba

511


How can you fetch common records from two tables?

589






Why partition by is used in sql?

554


What is group function in sql?

537


What are % type and % rowtype?

576


what is datawarehouse? : Sql dba

569


Where do we use pl sql?

554


how can we optimize or increase the speed of a mysql select query? : Sql dba

506


What is the difference between sql and mysql?

557


What is the meaning of disabling a trigger?

647


i have some prob lem to tell me about my self in interview first round ...

1702


how to rename an existing column in a table? : Sql dba

511