9.3 view / cross join / flat table solution

From: Wells Oliver <wellsoliver(at)gmail(dot)com>
To: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: 9.3 view / cross join / flat table solution
Date: 2014-10-18 19:13:00
Message-ID: CAOC+FBX8soovOV+Lsv=bc0Ku1qJpvC-mWW=bzKADb5Lz0Ei1bA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi everyone. I have a view setup like so:

create view myview as
select
department,
employee_id,
report_status,
sum(reports) reports
from logger.reports
group by department, employee_id, report_status;

Which gives me the total number of reports by status, which is either
'published' or 'finalized'.

What I don't get is an 'all' rollup. Which I could do with another flat
table and a cross join on a table of report statuses, but I'd love to keep
this is as a view if possible.

Using 9.3, so I have the "latest and greatest". What are my options here?

--
Wells Oliver
wellsoliver(at)gmail(dot)com

Responses

Browse pgsql-general by date

  From Date Subject
Next Message marin 2014-10-18 23:22:40 Re: Row number estimation...
Previous Message Tom Lane 2014-10-18 15:34:18 Re: Row number estimation...