I have a table that holds items:
id name groups
1 a1
2 a2 b1
3 a3
4 c1
5 c2
6 c3 b1
I’d like to figure out an effective way to sort these items by name if groups does not exist (read: has no entry – null), or if groups exists, sort using the groups.
So if I were to sort the following table, the result would be:
a1
a3
a2
c3
c1
c2
Any suggestions?
If “blank” means either
nullor'', use this:If “blank” means just
null, then this simpler version will work: