Originally posted by Kazan
SELECT * FROM cmppeople
WHERE Pos_Type='Scientists'
ORDER BY Pos_Type,Pos_SubType,OrderOverride,
SUBSTRING(Name, 1+Length(Name)-Locate(' ', REVERSE(Name))), SUBSTRING(Name, 1, Length(Name)-Locate(' ', REVERSE(Name)))
Well, it's been about 11/2 years since I last
looked at SQL, so allow me some leeway here.........especially as this is off the top of my head
SELECT * - show all record fields in the selected tuples
WHERE Pos_Type='Scientists' - I presume pos-type is a field name?
ORDER BY Pos_Type,Pos_SubType,OrderOverride,
SUBSTRING(Name, 1+Length(Name)-Locate(' ', REVERSE(Name))), SUBSTRING(Name, 1, Length(Name)-Locate(' ', REVERSE(Name)))
- ORDER BY - in terms of priority, I think it's left-right (high-low) - Poa_type field, Pos_SubType field, OrderOverride field,
- now this next bit is a little hazy in particular, due to my unfamiliarity with the inbuild funcitons -
SUBSTRING(Name, 1+Length(Name)-Locate(' ', REVERSE(Name))),
- the substring of the name field, taken from the last(?) whitespace
SUBSTRING(Name, 1, Length(Name)-Locate(' ', REVERSE(Name)))
- the substring of the name field, taken from the first(?) whitespace
So -
select and show all records
where pos_type (the field) is "Scientist"
order (the selected records) by Pos_type, Pos_SubType, OrderOverried, position of the last whitespace, position of the first whitespace (in order of priority)
Correct me it I'm wrong, it's nice to try and refresh these things from time to time.
EDIT: waittamo - this is (as a last resort)sorting by the length of the second or first name?