with MyData as ( select SuperThemeId ,SuperThemeName ,ThemeId ,ThemeName ,Qty = count(1) over (partition by SuperThemeId) from IncrThemeMapping ) select * from MyData where Qty > 1
OVER
select SuperThemeId ,SuperThemeName ,ThemeId ,ThemeName ,Qty = ( select count(1) from IncrThemeMapping where SuperThemeId = a.SuperThemeId ) from IncrThemeMapping a where 1=1 and SuperThemeId in ( select SuperThemeId from IncrThemeMapping group by SuperThemeId having count(1) > 1 )