Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9065861
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T16:36:43+00:00 2026-06-16T16:36:43+00:00

I have an Sql Server Query that is using the ROLLUP clause while grouping.

  • 0

I have an Sql Server Query that is using the ROLLUP clause while grouping. I want an equivalent query in Postgres. Query in SQl Server is:

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 > 0 AND reg_is_complete = false THEN 1 ELSE Null END) as regsInComplete,
       COUNT(CASE WHEN reg_frn_pro_id > 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 < #CreateODBCDate(url.endDate)#
AND   reg_date_created > #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
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T16:36:44+00:00Added an answer on June 16, 2026 at 4:36 pm
    with detail as (
        select
            acnt_dba_name as account,
            evt_name as event, 
            count(case reg_is_complete when true then 1 else null end) as regscomplete,
            count(case when reg_frn_pro_id > 0 and reg_is_complete = false then 1 else null end) as regsincomplete,
            count(case when reg_frn_pro_id > 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 < #CreateODBCDate(url.endDate)#
            AND reg_date_created > #CreateODBCDate(url.startDate)#
            and reg_is_active = true        -- only active regs
            and reg_is_test = false     -- only live registrations
        group by acnt_dba_name, evt_name
    ), account as (
        select
            account,
            '' as event, 
            sum(regscomplete) as regscomplete,
            sum(regsimcomplete) as regsincomplete,
            sum(regsclicks) as regsclicks
        from detail
        group by account
    ), total as (
        select
            'Total' as account,
            '' as event, 
            sum(regsComplete) as regsComplete,
            sum(regsImComplete) as regsInComplete,
            sum(regsClicks) as regsClicks
        from account
    )
    select * from detail
    union
    select * from account
    union
    select * from total
    order by account, event
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using SQL Server 2005 I have a query that gets child records from bundles
Using Microsoft SQL server 2008 I have a query that is in need of
We're using SQL Server 2000 Query Analyser, and one issue we have is that
I'm using Sql-Server, and I have the below query which returns all columns that
Scenario I'm using SQL Server 2005 I have a T-Sql query that has multiple
I am using SQL Server 2008. I want to write a query that gives
Edit: using SQL Server 2005. I have a query that has to check whether
I am using SQL Server 2008 and ColdFusion 9.1.2. I have a query that
I have a query that I run in SQL Server using Management Studio. The
I am using SQL Server 2008. I have a query that pulls two random

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.