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 / vivek nagarajan
SELECT SUM(DECODE(txt,'a',1)) a_count,
SUM(DECODE(txt,'b',1)) b_count,
SUM(DECODE(txt,'a',0,'b',0,1)) others_count
FROM t1;
| Is This Answer Correct ? | 2 Yes | 2 No |
Post New Answer View All Answers
How many tables can a sql database have?
Why are sql stored procedures used?
What is rowtype?
What is pl sql commands?
What is the usage of the distinct keyword?
What does plv msg allows you to do?
Is join and inner join the same?
Does inner join return duplicate rows?
Mention what are the benefits of pl/sql packages?
What is implicit cursor in pl sql?
What is trigger and types?
What is crud stand for?
What is clause?
How to look at the current sql*plus system settings?
What are the different types of tables in sql?