J
Jose Perdigao
To generate the following table,
Last AVG AVG
AREA - EQUIPMENT Day MTD YTD
Lombo-Skimmer 163 147 91
Lombo-Disposal Pile 54 35 33
Bagre-Skimmer 32 27 33
Essungo-Treater 0 0 0
Essungo-Skimmer 0 0 0
Essungo-Disposal Pile 0 0 0
Lombo-Fiscal Lact H2S 29 30 29
I created four queries,
a. A query to get the current data
SELECT PPMs.NameID, PPMs.PPM FROM PPMs WHERE (((PPMs.Date)=rptDate())) ORDER
BY PPMs.Sort;
b. A query to get average for the current month,
SELECT PPMs.NameID, Avg(PPMs.PPM) AS MTD
FROM PPMs
WHERE (((Month([Date]))=Month(rptDate())) AND
((Year([Date]))=Year(rptdate())))
GROUP BY PPMs.NameID, PPMs.Sort
ORDER BY PPMs.Sort;
c. A query to get data for current year,
SELECT PPMs.NameID, Avg(PPMs.PPM) AS YTD
FROM PPMs
WHERE (((Year([Date]))=Year(rptdate())))
GROUP BY PPMs.NameID, PPMs.Sort
ORDER BY PPMs.Sort;
d. A query using the queries above
SELECT Query1.NameID, Query1.Daily, Query2.MTD, Query3.YTD
FROM (Query1 INNER JOIN Query2 ON Query1.NameID = Query2.NameID) INNER JOIN
Query3 ON Query2.NameID = Query3.NameID
GROUP BY Query1.NameID, Query1.Daily, Query2.MTD, Query3.YTD;
Question.
Is it possible creating just one query, using sub queries in the columns and
the query is quickly?
Thanks
José Perdigão
Last AVG AVG
AREA - EQUIPMENT Day MTD YTD
Lombo-Skimmer 163 147 91
Lombo-Disposal Pile 54 35 33
Bagre-Skimmer 32 27 33
Essungo-Treater 0 0 0
Essungo-Skimmer 0 0 0
Essungo-Disposal Pile 0 0 0
Lombo-Fiscal Lact H2S 29 30 29
I created four queries,
a. A query to get the current data
SELECT PPMs.NameID, PPMs.PPM FROM PPMs WHERE (((PPMs.Date)=rptDate())) ORDER
BY PPMs.Sort;
b. A query to get average for the current month,
SELECT PPMs.NameID, Avg(PPMs.PPM) AS MTD
FROM PPMs
WHERE (((Month([Date]))=Month(rptDate())) AND
((Year([Date]))=Year(rptdate())))
GROUP BY PPMs.NameID, PPMs.Sort
ORDER BY PPMs.Sort;
c. A query to get data for current year,
SELECT PPMs.NameID, Avg(PPMs.PPM) AS YTD
FROM PPMs
WHERE (((Year([Date]))=Year(rptdate())))
GROUP BY PPMs.NameID, PPMs.Sort
ORDER BY PPMs.Sort;
d. A query using the queries above
SELECT Query1.NameID, Query1.Daily, Query2.MTD, Query3.YTD
FROM (Query1 INNER JOIN Query2 ON Query1.NameID = Query2.NameID) INNER JOIN
Query3 ON Query2.NameID = Query3.NameID
GROUP BY Query1.NameID, Query1.Daily, Query2.MTD, Query3.YTD;
Question.
Is it possible creating just one query, using sub queries in the columns and
the query is quickly?
Thanks
José Perdigão