|
Posted by Hugo Kornelis on 01/15/06 23:11
On 15 Jan 2006 10:09:18 -0800, stockblaster@gmail.com wrote:
>Hello
>
>I am sorry, i didn't explain my self what i wanted to acchive exactly.
(snip)
Hi Stockblaster,
That's exactly the reason why John suggested you to read the information
at www.aspfaq.com/5006 in his first post to you - posting CREATE TABLE
and INSERT statements and expected output is a much better way to
explain your needs than pure narrative.
If I understand your requirements correctly, then maybe something like
this will work:
SELECT t1.OrderId
FROM (SELECT TOP 4 OrderID
FROM Table1
ORDER BY OrderID DESC) AS t1
LEFT JOIN Table2 AS t2
ON t2.OrderId = t1.OrderId
AND t2.UserId = @UserId
WHERE t2.OrderID IS NULL
(untested - see www.aspfafq.com/5006 if you prefer a tested reply)
--
Hugo Kornelis, SQL Server MVP
Navigation:
[Reply to this message]
|