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

explain primary keys and auto increment fields in mysql : sql dba

512


What sql database should I use?

545


What is a pdo connection?

503


what is a table in a database ? : Sql dba

530


What are schema-level triggers?

570






What is a crud api?

489


Is inner join faster than left join?

619


What is an implicit commit?

541


Which certification is best for sql?

528


Describe types of sql statements?

537


What is nosql db?

528


what is a control file ? : Sql dba

566


Explain the savepoint statement.

588


How would you convert date into julian date format?

581


What is a primary key called that is made up of more than one field?

783