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
Why are cursors used?
Mention what plvcmt and plvrb does in pl/sql?
What is trigger with example?
Is vs as in pl sql?
what are local and global variables and their differences? : Sql dba
What is an oracle stored procedure?
What is query optimization in sql?
What is the difference among union, minus and intersect?
How do you optimize a query?
Does asenumerable execute the query?
Can we create index on primary key?
what is self join and what is the requirement of self join? : Sql dba
What is a string data type in sql?
what are the different index configurations a table can have? : Sql dba
How can we make an if statement within a select statement?