Sqlserver
 sql >> Datenbank >  >> RDS >> Sqlserver

Wie verwende ich count und Group By with Self Join in derselben Tabelle in 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