Posted by stockblaster on 01/15/06 20:09
Hello
I am sorry, i didn't explain my self what i wanted to acchive exactly.
For this query:
SELECT TOP 4 t1.OrderID
FROM TABLE1 t1
LEFT JOIN TABLE2 t2 ON t1.OrderId = t2.OrderId AND @UserId = t2.UserId
WHERE t2.OrderID IS NULL
ORDER BY t1.OrderID DESC
There is a problem with that..
For example:
Table1:
OrderID
1
2
3
4
5
6
7
8
Table2:
OrderID UserID
6 1001
7 1001
3 1002
4 1002
the result will be:
for user 1001
8
5
4
3
I only need to get 8 and 5 which are the two orderID's the user didn't
have from the top 4 in table 1 ..
can't figure that out :(
[Back to original message]
|