Sqlserver
 sql >> Base de Dados >  >> RDS >> Sqlserver

Como usar count e Group By com Self join na mesma tabela no sql server 2008?

select st_name, 
       count(*) as grp_cnt,
       (select count(distinct st_name) from your_table) as st_cnt
from your_table
group by st_name