title: PostgreSQL equivalent for SQL Server GROUP BY WITH ROLLUP
body: <p>I have an Sql Server Query that is using the <code>ROLLUP</code> clause while grouping. I want an equivalent query in Postgres. Query in SQl Server is:</p>
  
  <pre><code>SELECT (CASE WHEN acnt_dba_name Is Null THEN 'Total' ELSE acnt_dba_name END) as account,
         (CASE WHEN evt_name Is Null THEN '' ELSE evt_name END) as event, 
         COUNT(CASE reg_is_complete WHEN true THEN 1 ELSE Null END) as regsComplete,
         COUNT(CASE WHEN reg_frn_pro_id &gt; 0 AND reg_is_complete = false THEN 1 ELSE Null END) as regsInComplete,
         COUNT(CASE WHEN reg_frn_pro_id &gt; 0 THEN Null ELSE 1 END) as regsClicks
  FROM      registrations_view 
  LEFT JOIN events ON (evt_id = reg_frn_evt_id)
  LEFT JOIN accounts ON (acnt_id = evt_frn_acnt_id)
  WHERE reg_date_created &lt; #CreateODBCDate(url.endDate)#
  AND   reg_date_created &gt; #CreateODBCDate(url.startDate)#
  AND   reg_is_active = true      -- only active regs
  AND   reg_is_test = false       -- only live registrations
  -- AND  reg_is_denied = false         -- exclude denied reg statuses (include these for now RWB 8/7/2)
  GROUP BY rollup(acnt_dba_name, evt_name)
  -- Sort with Nulls at the bottom
  ORDER BY acnt_dba_name, evt_name
  </code></pre>