I am working with 2 tables:
Submissions: ID, submitdate, groupid, statusid (60,000)
Status: statusid, name (7)
Currently, I have a select statement which is using nested queries and outer joins to produce a grid table with a count of submissions per group, with a given statusid
ex table:
----------------Group1----------Group2
Active------------22----------------15
Terminated------15----------------15
Withdrawn-------12----------------15
This is fairly easy, because I know how many groups I have, so I have nested queries for each of the groups. Now my dilemma is that I want to break out the counts by year, but the number of years varies for each group...
The end goal is get the table to look like this:
-----------------G1FY1----------G1FY2------G2FY1------G2FY2------G2FY3
Active------------11---------------11---------5------------5-------------5
Terminated------2----------------13---------5-------------5------------5
Withdrawn-------1----------------11---------5-------------5------------5
Any ideas? My current select statement syntax is something like this:
select distinct
status.status_desc
g1.count
g2.count
from status
left outer join (
SELECT cs.status, count(g1.id) as count
FROM submissions
GROUP BY g1.status
) g1
on status.status = g2.status
left outer join (
SELECT cs.status, count(g2.id) as count
FROM submissions
GROUP BY g2.status
) g2
on status.status = g2.status
Any help is appreciated...
Submissions: ID, submitdate, groupid, statusid (60,000)
Status: statusid, name (7)
Currently, I have a select statement which is using nested queries and outer joins to produce a grid table with a count of submissions per group, with a given statusid
ex table:
----------------Group1----------Group2
Active------------22----------------15
Terminated------15----------------15
Withdrawn-------12----------------15
This is fairly easy, because I know how many groups I have, so I have nested queries for each of the groups. Now my dilemma is that I want to break out the counts by year, but the number of years varies for each group...
The end goal is get the table to look like this:
-----------------G1FY1----------G1FY2------G2FY1------G2FY2------G2FY3
Active------------11---------------11---------5------------5-------------5
Terminated------2----------------13---------5-------------5------------5
Withdrawn-------1----------------11---------5-------------5------------5
Any ideas? My current select statement syntax is something like this:
select distinct
status.status_desc
g1.count
g2.count
from status
left outer join (
SELECT cs.status, count(g1.id) as count
FROM submissions
GROUP BY g1.status
) g1
on status.status = g2.status
left outer join (
SELECT cs.status, count(g2.id) as count
FROM submissions
GROUP BY g2.status
) g2
on status.status = g2.status
Any help is appreciated...
