I have a select query that creates an Alias named Volume. Volume contains text and numbers. I want to sort the field Volume first by text (letters, a, b, c, d etc.) and then by numbers (1, 2, 3, etc.).
I can get the letters first then numbers in the query results. The numbers are sorting correctly, but the letters are sorting by c, b, x. Why would c come before b?
SELECT tblInstruments.InstrumentID, tblInstruments.Vol_txt,
tblInstruments.Vol_Num, IIf(IsNull([Vol_txt]),[Vol_num],[Vol_txt]) AS
Volume, tblInstruments.Page
FROM tblInstruments
ORDER BY IIf(IsNull([Vol_txt]),[Vol_num],[Vol_txt]);
You an change the sort order to start with text, then alphabet using Val
in the Order statement:
SELECT tblInstruments.InstrumentID, tblInstruments.Vol_txt,
tblInstruments.Vol_Num, IIf(IsNull([Vol_txt]),[Vol_num],[Vol_txt]) AS
Volume, tblInstruments.Page
FROM tblInstruments
ORDER BY Val (IIf(IsNull([Vol_txt]),[Vol_num],[Vol_txt]));
Thank you.
Robert
I can get the letters first then numbers in the query results. The numbers are sorting correctly, but the letters are sorting by c, b, x. Why would c come before b?
SELECT tblInstruments.InstrumentID, tblInstruments.Vol_txt,
tblInstruments.Vol_Num, IIf(IsNull([Vol_txt]),[Vol_num],[Vol_txt]) AS
Volume, tblInstruments.Page
FROM tblInstruments
ORDER BY IIf(IsNull([Vol_txt]),[Vol_num],[Vol_txt]);
You an change the sort order to start with text, then alphabet using Val
in the Order statement:
SELECT tblInstruments.InstrumentID, tblInstruments.Vol_txt,
tblInstruments.Vol_Num, IIf(IsNull([Vol_txt]),[Vol_num],[Vol_txt]) AS
Volume, tblInstruments.Page
FROM tblInstruments
ORDER BY Val (IIf(IsNull([Vol_txt]),[Vol_num],[Vol_txt]));
Thank you.
Robert