Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to get a Top n dataset grouped.
Message
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00680116
Message ID:
00681597
Views:
20
>>< snip >>
>>>Hi
>>>I'm afraid it will become too complcated and slow-running query but you caould try somethink like this:
>>>
 SELECT t.LotNumber, t.Container, t.Lot_Pieces, t.Lot_Balance FROM MyTable t
>>>     WHERE t.LotNumber IN (SELECT top 3 sq.LotNumber, sq.Container, sq.Lot_Balance
>>>                          FROM MyTable sq
>>>                          WHERE sq.Container = t.Container )
>>>
>>
>>First, in VFP SELECT TOP n requires ORDER BY clause. Second, such subquery would generate an error.
>
>Sergey, I know ORDER BY requirements and this is just an idea.
>Of course Martin should know how will he order the desired top 3 record (may be on LotNumber)
>I do not have the data to test it.
>Why do you think it will generate an error?

Venelina,

I tried many times to get subquery like that to work w/o any success.
--sb--
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform