azhutch
Technical User
- Jan 3, 2003
- 15
Can Anyone help me with finding where I have made the following error "The SELECT statement includes a reserved word or an argument name that is misspelled or missing, or the punctuation is incorrect." in the query statement:
SELECT a.Ticker AS Expr1, a.CoName AS Expr2, (Sum(PQuantityBefore)-Sum(SQuantityBefore)) AS BalanceBefore, Sum(a.QuantityPurchased) AS QuantityPurchased, Sum(a.QuantitySold) AS QuantitySold, (Sum(PQuantityBefore)-Sum(SQuantityBefore)+Sum(QuantityPurchased)-Sum(QuantitySold)) AS Balance
FROM (SELECT Ticker, CompanyName, Quantity AS pt.PQuantityBefore, 0 AS pt.SQuantityBefore, 0 AS QuantityPurchased, 0 AS pt.QuantitySold, pt.TradeDate FROM qryTransOpen pt
WHERE pt.TradeDate < [STARTDATE ]
UNION ALL
SELECT Ticker, CoName, 0 AS st.PQuantityBefore, Quantity AS SQuantityBefore, 0 AS st.QuantityPurchased, 0 AS st.QuantitySold, TradeDate FROM qryTransClose st
WHERE st.TradeDate < [STARTDATE
UNION ALL
SELECT Ticker, CoName, 0 AS pt.PQuantityBefore, 0 AS pt.SQuantityBefore, pt.Quantity AS QuantityPurchased, 0 AS pt.QuantitySold FROM qryTransOpen pt
WHERE pt.TradeDate BETWEEN [STARTDATE] AND [ENDDATE]
UNION ALL
SELECT Ticker, CompanyName, 0 AS st.PQuantityBefore, 0 AS st.SQuantityBefore,
0 AS st.QuantityPurchased, Quantity AS QuantitySold FROM qryTransClose st
) AS a
WHERE ((([st].[TradeDate]) Between [STARTDATE] And [ENDDATE]))
GROUP BY a.Ticker, a.CoName;
Any help would be greatly appreciated.
SELECT a.Ticker AS Expr1, a.CoName AS Expr2, (Sum(PQuantityBefore)-Sum(SQuantityBefore)) AS BalanceBefore, Sum(a.QuantityPurchased) AS QuantityPurchased, Sum(a.QuantitySold) AS QuantitySold, (Sum(PQuantityBefore)-Sum(SQuantityBefore)+Sum(QuantityPurchased)-Sum(QuantitySold)) AS Balance
FROM (SELECT Ticker, CompanyName, Quantity AS pt.PQuantityBefore, 0 AS pt.SQuantityBefore, 0 AS QuantityPurchased, 0 AS pt.QuantitySold, pt.TradeDate FROM qryTransOpen pt
WHERE pt.TradeDate < [STARTDATE ]
UNION ALL
SELECT Ticker, CoName, 0 AS st.PQuantityBefore, Quantity AS SQuantityBefore, 0 AS st.QuantityPurchased, 0 AS st.QuantitySold, TradeDate FROM qryTransClose st
WHERE st.TradeDate < [STARTDATE
UNION ALL
SELECT Ticker, CoName, 0 AS pt.PQuantityBefore, 0 AS pt.SQuantityBefore, pt.Quantity AS QuantityPurchased, 0 AS pt.QuantitySold FROM qryTransOpen pt
WHERE pt.TradeDate BETWEEN [STARTDATE] AND [ENDDATE]
UNION ALL
SELECT Ticker, CompanyName, 0 AS st.PQuantityBefore, 0 AS st.SQuantityBefore,
0 AS st.QuantityPurchased, Quantity AS QuantitySold FROM qryTransClose st
) AS a
WHERE ((([st].[TradeDate]) Between [STARTDATE] And [ENDDATE]))
GROUP BY a.Ticker, a.CoName;
Any help would be greatly appreciated.