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
what is the difference between union and union all? : Sql dba
Is t sql a programming language?
How do I access sql anywhere database?
What is sql keyword?
What is cursor status?
What operating systems are supported by oracle sql developer?
Explain dml and ddl?
Why schema is used in sql?
What are actual parameters and formal parameters?
What is compilation error in pl sql?
What mean sql?
what are the maximum number of rows that can be constructed by inserting rows directly in value list? : Transact sql
How do I view a procedure in sql?
What is difference between cursor and trigger?
What is cross join example?