Follow Our FB Page << CircleMedia.in >> for Daily Laughter. We Post Funny, Viral, Comedy Videos, Memes, Vines...



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








Answers were Sorted based on User's Feedback



Table name: T1, it has only one column. col1 ------ c b a b b b b d s a a t s ..

Answer / 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



More SQL PLSQL Interview Questions

IF EMP HAS 2 ROWS,DEPT HAS 4 ROWS.WHATS THE RESULT OF SELECT * FROM EMP,DEPT;

1 Answers  


How to get second highest salary from a table

3 Answers  


How to create your own reports in sql developer?

0 Answers  


Explain the types of joins in sql?

0 Answers  


HP Interview -2016 Unix 1) grep command in unix 2) what is set command

1 Answers   HCL,






What is the difference between union and union all command?

0 Answers  


What are the benefits of pl/sql packages?

0 Answers  


What are the two types of exceptions.

0 Answers  


What is full join in sql?

0 Answers  


What are the advantages of VIEW?

5 Answers  


What is the difference between a subquery and a join?

0 Answers  


What is procedure and function?

0 Answers  






Categories