Union Queries involving 2 Queries



I've been going through this over and over and I just need another pair
of eyes to look at this before I go nuts!!! I'm trying to combine two
queries so that I can create a crosstab table with names as row
headings, dates as column headings and the sum of the Counts as
Values...

My first query is as follows:
SELECT h.orderdate AS [Date], Count(h.invnumber) AS [Count],
LTrim(RTrim([fname]))+', '+LTrim(RTrim([lname])) AS Name
FROM dbo_npohdr AS h LEFT JOIN dbo_userlist AS u
ON h.origkey = u.userkey
GROUP BY h.orderdate, u.fname, u.lname
ORDER BY h.orderdate;

The second is:
SELECT h.receivedat AS [Date], Count(h.invkey) AS [Count],
LTrim(RTrim([fname]))+', '+LTrim(RTrim([lname])) AS Name
FROM dbo_imhdr AS h LEFT JOIN dbo_userlist AS u ON h.origkey =
u.userkey
GROUP BY h.receivedat, u.fname, u.lname
ORDER BY h.receivedat;

And the third and final one is giving me problems:

SELECT x.date, Sum(x.count) AS SumOfcount, x.name
FROM [select date, count, name
from [qry_Non-PO_Entry_by_Date]

union

select date, count, name
from [qry_PO-Match_by_Date]]. AS x
GROUP BY x.date, x.name;

I'm not sure where I went wrong? Can anyone help???

.



Relevant Pages

  • Re: Charlotte Church
    ... A Single Locust wrote: ... The eyes say no but the nuts say go. ... Everything I see and read about her leads me to suggest she's class ...
    (uk.media.tv.misc)
  • Re: Please! All who post here.
    ... It can drive me nuts sometimes when people do some things like this as well. ... Just take a look at this example from my great-aunt. ... > capitalize only the first letter of each sentence! ... > My eyes are really starting to hurt reading the posts from so many ...
    (microsoft.public.windowsxp.general)
  • Re: CBB; Is Faria Alam stacking on the timber?
    ... > She's what viz would call a borderline boiler ... > they eyes say no, the nuts say go! ...
    (uk.media.tv.misc)
  • Re: Vicki Butler Henderson - Borderline Boiler
    ... > The eyes say no, the nuts say go. ... > I cant decide if she's very plain and scrubs up well, ...
    (uk.media.tv.misc)
  • Re: Charlotte Church
    ... ||| The eyes say no but the nuts say go. ... There's no pleasing some people. ...
    (uk.media.tv.misc)