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 / kumarvijay
select decode(dept_id,1,1,2,2,0) "cnt" ,count(decode
(dept_id,1,1,2,2,0))
from deps group by decode(dept_id,1,1,2,2,0);
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
How do you optimize a stored procedure query?
Is trigger a stored procedure?
what are the different tables present in mysql, which type of table is generated when we are creating a table in the following syntax: create table employee (eno int(2),ename varchar(10)) ? : Sql dba
What is meant by cursor in sql?
how to extract a unit value from a date and time? : Sql dba
what is top in tsql? : Transact sql
How does cross join work?
How do we use distinct statement? What is its use?
Is primary key is clustered index?
What is the use of prepared statement?
How do I partition in sql?
What is insert command in sql?
Can we use ddl commands in pl sql?
What is database white box testing and black box testing?
Can a table contain multiple foreign key’s?