Can someone tell me if there is anything wrong with this statement. It pulls the right data in the first statement but always the wrong data in the second.
I want it to pull the last record in the table that meets the where clause?
The first statement pulls the last record (which is correct) while the 2nd statement is pulling the first right now?
SELECT top 1 (Inventory_ID), InvDate, [Inventory].[Opening]
FROM Inventory
WHERE [product_ID]=1 And [Location_ID]=1
order by Inventory_ID desc
UNION SELECT top 1 (Inventory_ID), InvDate, [Inventory].[Opening]
FROM Inventory
WHERE [product_ID]=1 And [Location_ID]=2
ORDER BY Inventory_ID DESC;
I want it to pull the last record in the table that meets the where clause?
The first statement pulls the last record (which is correct) while the 2nd statement is pulling the first right now?
SELECT top 1 (Inventory_ID), InvDate, [Inventory].[Opening]
FROM Inventory
WHERE [product_ID]=1 And [Location_ID]=1
order by Inventory_ID desc
UNION SELECT top 1 (Inventory_ID), InvDate, [Inventory].[Opening]
FROM Inventory
WHERE [product_ID]=1 And [Location_ID]=2
ORDER BY Inventory_ID DESC;