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
what is csv? : Sql dba
What is the difference between joins?
What is the file extension for sql database?
How do you optimize a stored procedure in sql?
What are the different sql commands?
what is sub-query? : Transact sql
what are the non-standard sql commands supported by 'mysql'? : Sql dba
what is sql in mysql? : Sql dba
What is the difference between left and left outer join?
What are different categories of sql commands?
What is a memo field?
What is memory optimized table?
Under what condition it is possible to have a page level lock and row lock at the same time for a query? : Transact sql
Mention what are the benefits of pl/sql packages?
What is the difference between local variables and global variables?