clear markdown compare help best fiddles feedback a leap of faith?
clear markdown donate comments/suggestions/bugs a leap of faith? bible365 diddy dollings
By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0. 1130652 fiddles created (16636 in the last week).

;with City AS (SELECT 'Count1' as Country,'St1' as State,'C1' as City,100 As Population Union ALL SELECT 'Count1', 'St1' , 'C2', 50 Union ALL SELECT 'Count1','St2' , 'CCC 1', 50 Union ALL SELECT 'Count1','St2' , 'CCC 2 ', 40 ) SELECT Country, State, SUM(Population) AS [Total] FROM ( SELECT Country, State, SUM(Population) AS [Population] FROM City GROUP BY Country, State HAVING SUM(Population) > 100 )A GROUP BY GROUPING SETS ( ( Country, State), ( Country), () ) HAVING SUM(Population) > 100 ORDER BY Country, State
Country State Total
Count1 150
Count1 St1 150
 hidden batch(es)