General information
Category:
Coding, syntax & commands
Charlie,
I guess your tip will help. I'll put an extra field in my cursor as,
SELECT substr(month,5,2)+substr(year,4,2) AS mysort FROM.... ORDER BY mysort
since it can kill 2 birds with one stone, as how Ed stated.
Thanks,
Gan
>>All,
>>
>>I'm using SQL Select to retrieve data from a few tables where one of the field in the cursor is "month".
>>
>>Example,
>>03/98
>>04/98
>>06/98
>>02/99
>>06/99
>>
>>For that, I need to put the order as,
>>ORDER BY SUBSTR(month,4,2),SUBSTR(month,1,2)
>>
>>However, this cannot be done because ORDER BY need to refer to a field, but not SUBSTR(...).
>>Any solution or good idea to this??
>>
>>Thanks,
>>Gan
>Try
>SELECT SUBSTR(Month,4,2) AS Year, SUBSTR(Month,1,2) AS Month FROM MyTable ORDER BY Year, Month
>or if you're happy with EXP_1, EXP_2 as field names
>SELECT SUBSTR(Month,4,2), SUBSTR(Month,1,2) FROM MyTable ORDER BY 2,1
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