SELECT field1 FROM table1 ORDER BY field2, field3
However I need to add something in so it also orders by a value that is returned from a calculation:
SELECT field1 FROM table1 ORDER BY field2, (if field 4==“” and field 5==1 then order these records in order), field3
So they are ordered by field2, then the calculation, then field3
SELECT field1 FROM table1 ORDER BY field2, CASE WHEN @a=1 Then UserName Else FirstName END
, field3
@a is an example variable here.
r937
3
what if field4 isn’t empty, or field 5 isn’t 1? what then?
Thanks webcosmo, I managed to work it out from this.
SELECT field1 FROM table1 ORDER BY field2, CASE WHEN field4='“” && field5=1 THEN 1 ELSE 0 END, field3