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
What is the difference between count 1 and count (*) in a sql query?
How do you modify a table in sql?
Explain what is rdbms?
What does := mean in pl sql?
What is the difference between microsoft access and sql server?
what are sequences
Which sorts rows in sql?
what is a materialized view? : Sql dba
Does sql between include endpoints?
List the different type of joins?
What is sqlcommand?
Which operator is used in query for pattern matching?
What are field types?
What trigger means?
How consistent is the view of the data between and within multiple sessions, transactions or statements ?