Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQL Help
Message
From
10/08/1999 07:48:50
 
 
To
10/08/1999 06:27:50
John Baird
Coatesville, Pennsylvania, United States
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
Miscellaneous
Thread ID:
00251416
Message ID:
00251898
Views:
9
Sorry, I thought you wrote that the UDF wouldn't work because you didn't know what the groups would be ahead of time. Glad you solved your problem.


>thanks for the input Bill. But I already had used the grouper UDF from the previous suggestion. It works like a charm.
>
>
>>It ain't pretty, but I think this works. You'll need to add housekeeping code.
>>
>>* Test is the table you described
>>
>>select *, recno() as rec from test into cursor t1 nofilter
>>index on grp_name to t1 unique
>>
>>copy to t2
>>
>>select t2.grp_name, t2.rec, test.subseq ;
>>from t2, test ;
>>where t2.grp_name = test.grp_name ;
>>order by rec
>>
>>
>>>Good idea, except that the groups can be anything. They come from a table that can be added to on the fly. I will never no what order the items appear in. Maybe if i use the grouper UDF and build an array as I pass the name in....
>>>
>>>Thanks for the idea..
>>>
>>>>
>>>>Don't you just need an ordering field based on Grp_Name?
>>>>SELECT Grouper(grp_name) AS Grouper, etc. ORDER BY Grouper, Subseq
>>>>where
>>>>Grouper is a UDF
>>>>FUNCTION Grouper
>>>>LPARAMETER GrpName
>>>>DO CASE
>>>>CASE m.GrpName = "input"
>>>>   RETURN "01"
>>>>CASE m.GrpName = "cables"
>>>>   RETURN "02"
>>>>MORE
>>>>
>>>>ENDCASE
>>>>Charlie
>>>>
>>>>>I have a table that contains numerous fields among which are<BR> grp_name and subseq in the following order:
>>>>>
>>>>>grp_name     subseq
>>>>>input          1
>>>>>cables         2
>>>>>education      3
>>>>>cables         4
>>>>>education      5
>>>>>cables         6
>>>>>input          7
>>>>>
>>>>>The problem I'm having is that the resulting cursor from the select <BR>must be ordered by grp_name (not alpahbetically but in the order they <BR>appear) and then by subseq in order ie:
>>>>>
>>>>>grp_name     subseq
>>>>>input          1
>>>>>input          7
>>>>>cables         2
>>>>>cables         4
>>>>>cables         6
>>>>>education      3
>>>>>education      5
>>>>>
>>>>>I have tried various combinations of Group By and Order By to no <BR>avail.  Any ideas?
>>>>>
>>>>>
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform