Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Ordering inside a group
Message
From
14/02/2001 20:03:54
 
 
To
14/02/2001 18:54:22
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00476088
Message ID:
00476105
Views:
27
>I have a SQL which is returning a set of records grouped. So, it goes like this:
>
>
>SELECT Field1,Field2,Field3,COUNT(*) FROM MyTable GROUP BY 2 ORDER BY 2 INTO CURSOR TEMP
>
>
>However, I would like to specify the order of the selected record within a group. So, for example, assuming I would have the first record to have a count of 3, which means I would have 3 records within that group, I would like to extract the record within that group which is ordered by Field2. By default, I believe it takes the last one it finds.

I'm not sure if I understood this completely but.......

I don't know how to do it in one query but
SELECT Field1,Field2,Field3 FROM MyTable ORDER BY 1,2 INTO CURSOR hold NOFILTER
SELECT Field1,Field2,Field3 FROM temp GROUP BY Field1 INTO CURSOR temp
gave me what I think you were asking for.

I've been wrong before!!!!!!

.....Rich
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform