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

select decode (col1,'a','a','b','b','others') col1,count(col1) from T1 group by decode (col1,'a','a','b','b','others')

Is This Answer Correct ?    9 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is full join?

512


How delete all data from all tables in sql?

530


Is pl sql a scripting language?

569


What is a nested table in word?

525


When is a declare statement required?

656






Is sqlite thread safe?

594


How do I write a cron which will run a sql query and mail the results to agroup?

513


What is the difference between clustered and non-clustered index in sql?

509


how can we know the number of days between two given dates using mysql? : Sql dba

535


Can we use ddl statements in stored procedure sql server?

503


write an sql query to get third maximum salary of an employee from a table named employee_table. : Sql dba

532


How do I tune a sql query?

501


Explain the commit statement.

600


What are joins in sql?

522


What programs use sql?

515