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 compilation error in pl sql?
What is t sql in sql server?
How do I find duplicates in a single column in sql?
Is it possible to pass parameters to triggers?
Does group by remove duplicates?
Suppose a student column has two columns, name and marks. How to get name and marks of the top three students.
What are the conditions an underlying table must satisfy before a cursor can be used by a positioned update or delete statement? : Transact sql
how to increment dates by 1 in mysql? : Sql dba
Does truncate free space?
Is it possible to create startup or shutdown trigger for on-schema?
What are the different parts of a package?
What is break?
What is function and procedure in pl sql?
Are null values same as that of zero or a blank space?
How many times can we commit in a loop?