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 decode(col1,'a','a','b','b','Other');

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How to assign sql query results to pl sql variables?

504


How do I run a query in pl sql developer?

550


When should I use nosql database?

544


How is indexing done in search engines?

521


Inline the values in PL/SQL, what does it mean.?

619






what is recursive stored procedure? : Sql dba

522


What is rowtype?

554


Which command is used to call a stored procedure?

489


What is 19 null in sql?

526


what is heap table? : Sql dba

598


What is a rank in sql?

527


What are tables and fields in the database?

545


Can function return multiple values in sql?

518


how many sql dml commands are supported by 'mysql'? : Sql dba

563


What is the difference between instead of trigger and after trigger?

502