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

select decode(dept_id,1,1,2,2,0) "cnt" ,count(decode
(dept_id,1,1,2,2,0))
from deps group by decode(dept_id,1,1,2,2,0);

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the difference between union and union all command?

547


What is sql basics?

578


What has stored procedures in sql and how we can use it?

563


How subquery works in sql?

541


What is plpgsql language?

529






What is having clause in sql?

527


What is clause?

608


What does cursor do in sql?

516


Is oracle sql free?

537


define data blocks ? : Sql dba

544


What are field types?

537


Which kind of parameters cannot have a default value in pl sql?

593


What are the two types of cursors in pl sql?

536


Which join is like inner join?

559


what is an execution plan? When would you use it? How would you view the execution plan? : Sql dba

547