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
explain primary keys and auto increment fields in mysql : sql dba
What sql database should I use?
What is a pdo connection?
what is a table in a database ? : Sql dba
What are schema-level triggers?
What is a crud api?
Is inner join faster than left join?
What is an implicit commit?
Which certification is best for sql?
Describe types of sql statements?
What is nosql db?
what is a control file ? : Sql dba
Explain the savepoint statement.
How would you convert date into julian date format?
What is a primary key called that is made up of more than one field?