Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Possible Union Query and need help 1

Status
Not open for further replies.

kentwoodjean

Technical User
Oct 19, 2002
376
US
I have been trying different things for about 2 hours off and on and need some advise/assistance. I have 2 queries that I am attempting to join. WritClosed (made from 3 queries) and Tele(made from 1 query). Each by themselves works perfectly and gives me the correct information by date. Together, it causes my counts from the Tele Q to double. Tried different join options, but no luck. Here is the SQL on my attempt to joint these 2 queries:


SELECT [POS DailyTot].ToDate, [SumOfAns]/[SumOfTotHandled] AS AvTSF, Sum([POS DailyTot].TotOffer) AS SumOfTotOffer, Sum([POS DailyTot].TotHandled) AS SumOfTotHandled, Sum([POS DailyTot].TotAband) AS SumOfTotAband, [SumofTotAband]/[SumOfTotOffer] AS PercentOfCanc, Sum([POS DailyTot].As) AS SumOfAs, [SumOfAs]/[SumOfTotHandled] AS AvgASA, Sum([POS DailyTot].Ans) AS SumOfAns, Avg([POS DailyTot].ATT) AS AvgOfATT, [SumOfAw]/[SumOfTotOffer] AS AvgWrap, Sum([POS DailyTot].Aw) AS SumOfAw, ReceivedAndClosedCountsbyDate.[Recd Dt], ReceivedAndClosedCountsbyDate.[CountOfRecd Dt], ReceivedAndClosedCountsbyDate.[CountOfClosed Dt], ReceivedAndClosedCountsbyDate.EndInv
FROM [POS DailyTot] LEFT JOIN ReceivedAndClosedCountsbyDate ON [POS DailyTot].ToDate = ReceivedAndClosedCountsbyDate.[Recd Dt]
GROUP BY [POS DailyTot].ToDate, ReceivedAndClosedCountsbyDate.[Recd Dt], ReceivedAndClosedCountsbyDate.[CountOfRecd Dt], ReceivedAndClosedCountsbyDate.[CountOfClosed Dt], ReceivedAndClosedCountsbyDate.EndInv
HAVING ((([POS DailyTot].ToDate) Between #1/1/2004# And #12/31/2004#) AND ((ReceivedAndClosedCountsbyDate.[Recd Dt])=[ToDate]));

I previously learned from this forum what a Union Query was and how to do one. I have done 2 since then and through trial and error got them working. Do I need a union query here, and if so, can someone assist me please. What I have here is a bit more complicated than the other ones I did.
 
I use this to pull all data from BOTH queries
SELECT [SeverityStage], [Platform], [Storage], [Software]
FROM [qryESGOpenPTRfrm_Step1ChartPriorityDataAll]

UNION ALL SELECT[SeverityStage], [Platform], [Storage], [Software]
FROM [qryESGOpenPTRfrm_Step2ChartPriorityDataTFD];

And this for uniquedata, its combines the non-unique data and list the unique seperately note the use of Union ALL...

SELECT [ESGCategoryId], [LogFileId], [Issue Id], [IssueAddress], [Project], [Severity], [Submitter], [Title], [Owner], [State], [daysopen], [DaysSinceModified], [Target Fix Date]
FROM [qryESGOpenPTR_frmTop5]

UNION SELECT [ESGCategoryId], [LogFileId], [Issue Id], [IssueAddress], [Project], [Severity], [Submitter], [Title], [Owner], [State], [daysopen], [DaysSinceModified], [Target Fix Date]
FROM [qryESGOpenPTR_Severity1]
ORDER BY [DaysOpen] DESC;
 
Sorry for the late reply to your response. I have been out of town on business. I do want to say "Thanks" as you gave me what I needed to get started. I have it working just right now.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top