General information
Category:
Databases,Tables, Views, Indexing and SQL syntax
>>This will be make two order by with two fields as independent:
>>select TOP 1 CONVERT(VARCHAR(10),DATE_FLD,101) + STR(ORDER_NO), FIELD2, FIELD3 from MyTable order by DATE_FLD, ORDER_NO DESC
>>
>>Try this one:
>>select TOP 1 CONVERT(VARCHAR(10),DATE_FLD,101) + STR(ORDER_NO), FIELD2, FIELD3 from MyTable order by 1 DESC
>
>Is this VFP or TSQL? Because convert(..., 101) looks like TSQL, and I'm not sure „order by 1“ is allowed in TSQL. Last time I tried you had to repeat the whole expression in the order by clause.
>Also, I'd make the str() use fixed with, so not to make 101 come before 2 in case the results are left aligned.
>
>Other than that, yup, this would work, but then why not
>
>select top 1 date_fld, order_no, field2, field3 order by date_fld desc, order_no
Yes, sql server supports order by 1, I don't remember last time when I used VFP. :)
If you want to order by combined field using like order by 1,2 would be better.
Previous
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only