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

Which sql statement is used to delete data from a database?

431


What is sp_helptext?

565


How will you distinguish a global variable with a local variable in pl/sql?

597


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

519


What is sql lookup?

493






How to run pl sql program in mysql?

488


Explain what is a field in a database and record in a database?

586


what is sql server agent? : Sql dba

575


What is a sql trace file?

527


Can a select statement fire a trigger?

625


Is time a data type in sql?

457


what is commit? : Sql dba

595


What is #table in sql?

498


Explain the difference in execution of triggers and stored procedures?

545


What is the difference between left outer join and left join?

493