Skip to Content
0
Jul 30, 2016 at 10:34 AM

Union Query with Where statement

74 Views

Experts,

I need to list Inventory Transfer, Deliveries and Service Call details and were able to do so. Now I need to add a Where statement that let's the user choose for which BP this details need to display.

Here is what I have:

SELECT T0.[DocNum], T0.[ObjType], T0.[CardCode], T0.[CardName], T0.[DocDate], T1.[ItemCode], T1.[Quantity], T1.[WhsCode] FROM ODLN T0 INNER JOIN DLN1 T1 ON T0.[DocEntry] = T1.[DocEntry]

UNION ALL

SELECT T0.[DocNum], T0.[ObjType], T0.[CardCode], T0.[CardName], T0.[DocDate], T1.[ItemCode], T1.[Quantity], T1.[WhsCode] FROM OWTR T0 INNER JOIN WTR1 T1 ON T0.[DocEntry] = T1.[DocEntry]

UNION ALL

SELECT T0.[callID], T0.[ObjType], T0.[customer], T0.[custmrName], T0.[createDate], T0.[ItemCode],T0.[RemQty], T0.[customer] FROM OSCL T0

ORDER BY T0.[CardCode]


WHERE T0.[CardName] = [%0]

I get an error as soon as I add the Where statement.

Your help will be greatly appreciatedMarli