Wednesday 29 June 2011

write a sql query to get the id and how many times its count of repetition and there u shouldn't get the distinct(i.e id-3)


I am having a table with columns
ID  NAME                                               
 1  x                                 And the requirement is to get the o/p like this  
 1  y                                 ID     Count(*)    
 1  z                                  1      3 
 2  a                                  2      2 
 2  b                                    
 3  c


The Query is:



select id,count(*) from group by id having count(*)>1;

No comments:

Post a Comment