G
Guest
I am trying to obtain the top AND bottom 25 values in the same query for a
report.
The only difference is the sort order on the pertinent field but I get an
error telling me I have different fields.
SELECT DISTINCT TOP 25 qry_PACONT09.Dept, qry_PACONT09.PTNumber,
qry_PACONT09.Name, qry_PACONT09.PROC, qry_PACONT09.Description,
qry_PACONT09.IndAmt, PAPME42C_5_5.Amt, [Indamt]-[amt] AS Difference,
qry_PACONT09.ChargeDate
FROM qry_PACONT09 LEFT JOIN PAPME42C_5_5 ON qry_PACONT09.PROC =
PAPME42C_5_5.PROC
WHERE (((qry_PACONT09.Dept)<>736) AND
((qry_PACONT09.ChargeDate)=[Forms]![frm_Reports]![RptDate]))
ORDER BY [Indamt]-[amt] DESC;
Union All
SELECT DISTINCT TOP 25 qry_PACONT09.Dept, qry_PACONT09.PTNumber,
qry_PACONT09.Name, qry_PACONT09.PROC, qry_PACONT09.Description,
qry_PACONT09.IndAmt, PAPME42C_5_5.Amt, [Indamt]-[amt] AS Difference,
qry_PACONT09.ChargeDate
FROM qry_PACONT09 LEFT JOIN PAPME42C_5_5 ON qry_PACONT09.PROC =
PAPME42C_5_5.PROC
WHERE (((qry_PACONT09.Dept)<>736) AND
((qry_PACONT09.ChargeDate)=[Forms]![frm_Reports]![RptDate]))
ORDER BY [Indamt]-[amt]
Can anyone tell me how to resolve the issue? Thanks in advance.
report.
The only difference is the sort order on the pertinent field but I get an
error telling me I have different fields.
SELECT DISTINCT TOP 25 qry_PACONT09.Dept, qry_PACONT09.PTNumber,
qry_PACONT09.Name, qry_PACONT09.PROC, qry_PACONT09.Description,
qry_PACONT09.IndAmt, PAPME42C_5_5.Amt, [Indamt]-[amt] AS Difference,
qry_PACONT09.ChargeDate
FROM qry_PACONT09 LEFT JOIN PAPME42C_5_5 ON qry_PACONT09.PROC =
PAPME42C_5_5.PROC
WHERE (((qry_PACONT09.Dept)<>736) AND
((qry_PACONT09.ChargeDate)=[Forms]![frm_Reports]![RptDate]))
ORDER BY [Indamt]-[amt] DESC;
Union All
SELECT DISTINCT TOP 25 qry_PACONT09.Dept, qry_PACONT09.PTNumber,
qry_PACONT09.Name, qry_PACONT09.PROC, qry_PACONT09.Description,
qry_PACONT09.IndAmt, PAPME42C_5_5.Amt, [Indamt]-[amt] AS Difference,
qry_PACONT09.ChargeDate
FROM qry_PACONT09 LEFT JOIN PAPME42C_5_5 ON qry_PACONT09.PROC =
PAPME42C_5_5.PROC
WHERE (((qry_PACONT09.Dept)<>736) AND
((qry_PACONT09.ChargeDate)=[Forms]![frm_Reports]![RptDate]))
ORDER BY [Indamt]-[amt]
Can anyone tell me how to resolve the issue? Thanks in advance.