PostgreSQL
 sql >> डेटाबेस >  >> RDS >> PostgreSQL

रोलअप के साथ SQL सर्वर ग्रुप के लिए PostgreSQL समकक्ष

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


  1. Database
  2.   
  3. Mysql
  4.   
  5. Oracle
  6.   
  7. Sqlserver
  8.   
  9. PostgreSQL
  10.   
  11. Access
  12.   
  13. SQLite
  14.   
  15. MariaDB
  1. Pg . में एक दूसरे से सटे दो शब्दों वाले वाक्य खोजें

  2. यदि इंट्राएरे एक्सटेंशन स्थापित है तो पोस्टग्रेज पूर्णांक सरणी पर अनुक्रमणिका का उपयोग नहीं करता है

  3. PostgreSQL के साथ स्थिर Qt 5.10.0 संकलित करते समय त्रुटि

  4. PostgreSQL रेगेक्स वर्ड सीमाएं?

  5. एक पोस्टग्रेज सुपरयुसर क्या है