From: ram on
HI All,

In the subquery below how would I refer to the lowest 3 orderID?

Thanks in advance for any help

SELECT Orders.CustomerID, Orders.OrderDate, Orders.OrderID
FROM Orders
WHERE Orders.OrderID IN
(SELECT TOP 3 OrderID
FROM Orders AS Dupe
WHERE Dupe.CustomerID = Orders.CustomerID
ORDER BY Dupe.OrderDate DESC, Dupe.OrderID DESC)
ORDER BY Orders.CustomerID, Orders.OrderDate, Orders.OrderID
From: Jerry Whittle on
ORDER BY Dupe.OrderDate DESC, Dupe.OrderID ASC)

You might need to remove " Dupe.OrderDate DESC, " if you are just interested
in the OrderID.
--
Jerry Whittle, Microsoft Access MVP
Light. Strong. Cheap. Pick two. Keith Bontrager - Bicycle Builder.


"ram" wrote:

> HI All,
>
> In the subquery below how would I refer to the lowest 3 orderID?
>
> Thanks in advance for any help
>
> SELECT Orders.CustomerID, Orders.OrderDate, Orders.OrderID
> FROM Orders
> WHERE Orders.OrderID IN
> (SELECT TOP 3 OrderID
> FROM Orders AS Dupe
> WHERE Dupe.CustomerID = Orders.CustomerID
> ORDER BY Dupe.OrderDate DESC, Dupe.OrderID DESC)
> ORDER BY Orders.CustomerID, Orders.OrderDate, Orders.OrderID
From: ram on
Thank you Jerry just what I needed

"Jerry Whittle" wrote:

> ORDER BY Dupe.OrderDate DESC, Dupe.OrderID ASC)
>
> You might need to remove " Dupe.OrderDate DESC, " if you are just interested
> in the OrderID.
> --
> Jerry Whittle, Microsoft Access MVP
> Light. Strong. Cheap. Pick two. Keith Bontrager - Bicycle Builder.
>
>
> "ram" wrote:
>
> > HI All,
> >
> > In the subquery below how would I refer to the lowest 3 orderID?
> >
> > Thanks in advance for any help
> >
> > SELECT Orders.CustomerID, Orders.OrderDate, Orders.OrderID
> > FROM Orders
> > WHERE Orders.OrderID IN
> > (SELECT TOP 3 OrderID
> > FROM Orders AS Dupe
> > WHERE Dupe.CustomerID = Orders.CustomerID
> > ORDER BY Dupe.OrderDate DESC, Dupe.OrderID DESC)
> > ORDER BY Orders.CustomerID, Orders.OrderDate, Orders.OrderID