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 / dinakar
select col1,count(*) cnt from T1 where col1 in
(select distinct col1 from T1 )
group by col1
| Is This Answer Correct ? | 1 Yes | 6 No |
Post New Answer View All Answers
how many sql ddl commands are supported by 'mysql'? : Sql dba
What is composite primary key in sql?
What does bitemporal mean?
What happens when a trigger is associated to a view?
What is difference between pl and sql?
what is the difference between nested subquery and correlated subquery?
What is a primary key? Explain
What is rename command in sql?
How to assign sql query results to pl sql variables?
Can we create a trigger on view?
Why is sql*loader direct path so fast?
Can we write dml inside a function in sql server?
What is an implicit commit?
How can you tell the difference between an index and a view?
what are all types of user defined functions? : Sql dba