MERGING TWO QUERIES
From: Kelli McCann (KelliMcCann_at_discussions.microsoft.com)
Date: 09/03/04
- Next message: Les: "Building a query"
- Previous message: Peter Martin: "RE: Random ID selection"
- Next in thread: Douglas J. Steele: "Re: MERGING TWO QUERIES"
- Reply: Douglas J. Steele: "Re: MERGING TWO QUERIES"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 3 Sep 2004 08:03:07 -0700
Hello,
Below I will post my two queries and the SQL view. I am wondering if these
two queries could actually just be one query. The information comes from two
different tables. If this is possible could someone please post the SQL view
of what the query would look like because I am having some difficulties.
COST PER MONTH - Query:
SELECT [Maintenance Purchases].TruckID AS TruckID, Sum([Maintenance
Purchases].Amount) AS Amount, Format([InvoiceDate],"mmm") AS [Month],
DatePart("yyyy",[InvoiceDate]) AS [Year]
FROM [Maintenance Purchases]
WHERE (((DatePart("yyyy",[InvoiceDate])) Between 2003 And 2004))
GROUP BY [Maintenance Purchases].TruckID, Format([InvoiceDate],"mmm"),
DatePart("yyyy",[InvoiceDate]), DatePart("m",[InvoiceDate])
HAVING ((([Maintenance Purchases].TruckID)="00-66"))
ORDER BY [Maintenace Purchases].TruckID, DatePart("yyyy",[InvoiceDate]),
DatePart("m",[InvoiceDate]);
MILES PER MONTH - Query:
SELECT Mileage.TruckID AS TruckID, Sum(Mileage.Miles) AS Miles,
Format([MilesDate],"mmm") AS [Month], DatePart("yyyy",[MilesDate]) AS [Year]
FROM Mileage
WHERE (((DatePart("yyyy",[MilesDate])) Between 2003 And 2004))
GROUP BY Mileage.TruckID, Format([MilesDate],"mmm"),
DatePart("yyyy",[MilesDate]), DatePart("m",[MilesDate])
HAVING (((Mileage.TruckID)="00-66"))
ORDER BY Mileage.TruckID, DatePart("yyyy",[MilesDate]),
DatePart("m",[MilesDate]);
Any help would be great. Thanks. Kelli
- Next message: Les: "Building a query"
- Previous message: Peter Martin: "RE: Random ID selection"
- Next in thread: Douglas J. Steele: "Re: MERGING TWO QUERIES"
- Reply: Douglas J. Steele: "Re: MERGING TWO QUERIES"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|