Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQL command
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Miscellaneous
Thread ID:
00251982
Message ID:
00251993
Views:
9
>Anyone know how to return groups of a particular number.
>I want it to work like TOP 3 but within groups.
>For example I want to generate a cursor that lists all orders but only the first 3 or so line items.
>
>Assuming that all orders have more than 3 items and I want to see the the first 3 of each; I would want to show the following and pitch anything else.
>
>OrderId1
> Item1
> Item2
> ITem3
>OrderId2
> Item1
> Item2
> ITem3
>
>Thanks,
>Chris

Haven't tried it, but you should be able to do something like this:

SELECT OrderID, OrderItem ;
FROM Orders O ;
WHERE OrderItem IN ;
(SELECT TOP 3 OrderItem;
FROM Orders O2 ;
WHERE OrderID = O.OrderID)
Erik Moore
Clientelligence
Previous
Reply
Map
View

Click here to load this message in the networking platform