C
ctdak
I did a mock up in Access query view before creating the following SQL code. I created two queries and linked them - the results were exactly what I need for a report.
Now I am trying to translate this into an SQL statement but I'm having trouble. I'm very inexperienced at SQL. Here's what I have:
SELECT * FROM [tbl_History] AS DetailQry
INNER JOIN
(SELECT [tbl_History].[HistAccountNo]
FROM [tbl_History] AS SubQry
WHERE SubQry.[HistReceiptDate]
BETWEEN #06/01/2003# AND #04/30/2004# AND
SubQry.[HistTaxDed] = TRUE AND
SubQry.[HistFundNo] = 4282
GROUP BY SubQry.[HistAccountNo]
HAVING SUM(SubQry.[HistAmt]) >= 1000) AS SummaryQry
ON DetailQry.[HistAccountNo] = SummaryQry.[HistAccountNo]
WHERE DetailQry.[HistReceiptDate]
BETWEEN #06/01/2003# AND #04/30/2004# AND
DetailQry.[HistTaxDed] = TRUE AND
DetailQry.[HistFundNo] = 4282
I don't know if I'm using the "AS" alias names correctly and so far I am getting an error message: "The specified field 'HistAccountNo' could refer to more than one table listed in the FROM clause of your SQL statement."
Any help to get this code to work would be much appreciated.
Thanks.
ctdak
Now I am trying to translate this into an SQL statement but I'm having trouble. I'm very inexperienced at SQL. Here's what I have:
SELECT * FROM [tbl_History] AS DetailQry
INNER JOIN
(SELECT [tbl_History].[HistAccountNo]
FROM [tbl_History] AS SubQry
WHERE SubQry.[HistReceiptDate]
BETWEEN #06/01/2003# AND #04/30/2004# AND
SubQry.[HistTaxDed] = TRUE AND
SubQry.[HistFundNo] = 4282
GROUP BY SubQry.[HistAccountNo]
HAVING SUM(SubQry.[HistAmt]) >= 1000) AS SummaryQry
ON DetailQry.[HistAccountNo] = SummaryQry.[HistAccountNo]
WHERE DetailQry.[HistReceiptDate]
BETWEEN #06/01/2003# AND #04/30/2004# AND
DetailQry.[HistTaxDed] = TRUE AND
DetailQry.[HistFundNo] = 4282
I don't know if I'm using the "AS" alias names correctly and so far I am getting an error message: "The specified field 'HistAccountNo' could refer to more than one table listed in the FROM clause of your SQL statement."
Any help to get this code to work would be much appreciated.
Thanks.
ctdak