Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You could use a Union statement and just add a null column in for each. Like this:</p> <pre><code>select fac_name, datename(month,b.startdt) as 'month', year(b.startdt) as 'year', count(a.empfk) as '#filled' , '' as 'capacity' from tbl_tmx_attempt a left outer join tbl_tmx_activity b on a.activityfk = b.activity_pk left outer join tbl_tmx_actloc c on b.activity_pk = c.activityfk left outer join loc d on c.locfk = d.loc_pk left outer join fac e on d.loc_facfk = e.fac_pk where b.startdt &gt; '12/31/08' group by fac_name, year(b.startdt), month(b.startdt), datename(month,b.startdt) Union All select fac_name, datename(month,b.startdt) as 'month', year(b.startdt) as 'year', '' as '#filled', sum(b.maxcapacity) as 'capacity' from tbl_tmx_activity b left outer join tbl_tmx_actloc c on b.activity_pk = c.activityfk left outer join loc d on c.locfk = d.loc_pk left outer join fac e on d.loc_facfk = e.fac_pk where b.startdt &gt; '12/31/08' group by fac_name, year(b.startdt), month(b.startdt), datename(month,b.startdt) </code></pre> <p>If this fails to work because you can't do a group by then try inserting the rows into a temp table with both capacity and #filled columns. You would just leave one empty for each insert. If what you are looking for is 1 row with both results then I would do the same as above except insert the results into 2 separate temp tables and do an OUTER JOIN on their unique Columns which I think would be fac_name, month, and year. Comment on my post if that doesn't work or isn't what you are trying to do.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload