I don't understand how I have to join 3 queries in order to get results
like
this:
| COMPANY | TOTAL | LAST_MONTH | LAST_WEEK |
-total queries-
SELECT tbl_total.PO_NAME, Sum(tbl_total.TOTAL) AS TOTAL,
Sum(tbl_total.CHARGE) AS CHARGE, Sum(tbl_total.PACKING) AS PACKING,
Sum(tbl_total.GLASS) AS GLASS, Sum(tbl_total.PAYMENT) AS PAYMENT,
Sum(tbl_total.OTHER) AS OTHER,
Sum(tbl_total.TOTAL)+Sum(tbl_total.CHARGE)+Sum(tbl_total.PACKING)+Sum(tbl_total.GLASS)+Sum(tbl_total.PAYMENT)+Sum(tbl_total.OTHER)
AS ["*SUM*"]
FROM tbl_total
GROUP BY tbl_total.PO_NAME;
-last month query-
SELECT tbl_total.PO_NAME, Sum(tbl_total.TOTAL) AS TOTAL,
Sum(tbl_total.CHARGE) AS CHARGE, Sum(tbl_total.PACKING) AS PACKING,
Sum(tbl_total.GLASS) AS GLASS, Sum(tbl_total.PAYMENT) AS PAYMENT,
Sum(tbl_total.OTHER) AS OTHER,
Sum(tbl_total.TOTAL)+Sum(tbl_total.CHARGE)+Sum(tbl_total.PACKING)+Sum(tbl_total.GLASS)+Sum(tbl_total.PAYMENT)+Sum(tbl_total.OTHER)
AS LAST_MONTH
FROM tbl_total
WHERE (((Exists (SELECT tbl_total.PO_NAME, tbl_total.TOTAL,
tbl_total.CHARGE, tbl_total.PACKING, tbl_total.GLASS, tbl_total.PAYMENT,
tbl_total.OTHER,
(tbl_total.TOTAL+tbl_total.CHARGE+tbl_total.PACKING+tbl_total.GLASS+tbl_total.PAYMENT+tbl_total.OTHER)
AS [LAST_MONTH]
FROM tbl_total
WHERE (((tbl_total.SHIPPING_DATE) Between
DateSerial(Year(Date()),Month(Date()),0) And Date()))))<>False) AND
((tbl_total.SHIPPING_DATE) Between
DateSerial(Year(Date()),Month(Date()),0)
And Date()))
GROUP BY tbl_total.PO_NAME;
-last week query-
SELECT tbl_total.PO_NAME, tbl_total.TOTAL, tbl_total.CHARGE,
tbl_total.PACKING, tbl_total.GLASS, tbl_total.PAYMENT, tbl_total.OTHER,
(tbl_total.TOTAL+tbl_total.CHARGE+tbl_total.PACKING+tbl_total.GLASS+tbl_total.PAYMENT+tbl_total.OTHER)
AS LAST_WEEK
FROM tbl_total
WHERE (((tbl_total.SHIPPING_DATE) Between Date()-Weekday(Date())+1 And
Date()));
Arvin Meyer said:
You could probably do this in a single query, but since you already have
the
3, I'd use them. Join the 3 queries in a new query, just like you would
tables, on Company, or better yet on CompanyID, put the 3 columns in (1
from
each) and use that new query as a recordsource for your report.
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com
.