Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sort Order Problem

Status
Not open for further replies.

mikelev

Technical User
Mar 23, 2004
223
US
I have a query that works fine except the order by clause.

The following order by clause I get:
Code:
ORDER BY VAL([TABLES Query].TABLENUM);
P5
P4
P3
P2
P1
1
2
3
4
5
6
7
8
9
10


I would like the P* values at the bottom:

1
2
3
4
5
6
7
8
9
10
P1
P2
P3
P4
P5

Is this possible?

Cheers,
 
Not sure u can do it easily in a single Order by. Perhaps consider adding a constructed field, where as it is dervied from the field. For example, IIF(Mid(FieldName,1,1)="P", "A","B"). Then sort on that field, along with the current field.

Select IIF(Mid(FieldName,1,1)="P", "A","B") as SortField, FieldName
from xTable
order by 1,2


htwh,

Steve Medvid
"IT Consultant & Web Master"

Chester County, PA Residents
Please Show Your Support...
 
ORDER BY IIf([TABLES Query].TABLENUM Like '#*', VAL([TABLES Query].TABLENUM),[TABLES Query].TABLENUM);

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Thanks for the responses. I was able to resolve the issue by adding a column "Sort" to the TABLES table and applying a numeric value to get them sorted the way I wanted.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top