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 / rakesh prasad

select name ,count(name)as cnt from (
select case when ((name ='a') or (name = 'b') )then name
else
'others' end as 'name' from tbl_count ) as temp group by
name

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Why are cursors used?

583


Mention what plvcmt and plvrb does in pl/sql?

641


What is trigger with example?

565


Is vs as in pl sql?

494


what are local and global variables and their differences? : Sql dba

540






What is an oracle stored procedure?

590


What is query optimization in sql?

550


What is the difference among union, minus and intersect?

546


How do you optimize a query?

538


Does asenumerable execute the query?

603


Can we create index on primary key?

524


what is self join and what is the requirement of self join? : Sql dba

683


What is a string data type in sql?

514


what are the different index configurations a table can have? : Sql dba

575


How can we make an if statement within a select statement?

543