Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Parameters for Order by in SQL?
Message
From
28/08/1998 12:46:45
 
 
To
28/08/1998 11:34:04
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00131023
Message ID:
00131064
Views:
16
>>I read a tip in July's Foxpro Advisor that you can use paramters for other than the where clause in an SQL view, fox example the Order by (provided you use the numeric construct, e.g. ORDER BY 2, instead of the field name). I couldn't get it to work however (got an error when I included ORDER BY ?testorde after setting testorde to 2 in the command window). Has anyone had any success or attempted this?
>>
>>I was intrigued by the idea as I'm trying to create an SQL for a report, but my users want to have flexibility in how it is ordered: Alphabetically, by District, or by Category. I don't want to create many different instances of the same SQL for this purpose. Perhaps I'm overlooking something obvious or another way to allow for this flexibility.
>>
>>I'd appreciate any ideas.
>>
>>TIA
>>
>>Sylvia
>
>n="1"
>select * from table1 order by &n.
>n="2"
>select * from table1 order by &n.

Ed -

Thanks a lot - this worked (I also found I can use something like "6,5" in N to order by two or more fields). I see you used macro substitution as opposed to the parameterized notation (?somefield) the article indicated could be used. Given that, is there any advantage to using the field number in this kind of situation instead of the field name (or doesn't it make a difference)?

Sylvia
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform