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 / sankarapandian
SELECT SUM(case when col1='a' then 1 else 0 end) a_count,
SUM(case when col1='b' then 1 else 0 end)
b_count,
sum(case when col1!='a' and col1!='b' then 1
else 0 end)other_count
FROM t1
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
Differentiate between sga and pga.
What are the two types of cursors in pl sql?
what are the t string functions available in tsql? : Transact sql
What are the two different parts of the pl/sql packages?
What are the advantages of stored procedure?
What is nvarchar in sql?
How much ram can sql express use?
How do I find duplicates in sql?
What is auto increment in sql?
Why we use triggers in mysql?
Is drop table faster than truncate?
Where are my tempfiles, I don't see them in v$datafile or dba_data_file?
What is a temporal data type?
What are the usages of sql?
What is pls_integer in pl sql?