I have the following query:
SELECT id, title, adcontent, adtargetURL, locationpage, locationarg, locationid, displayorder, visible, schedstart, schedstop, created, modified, createdby, modifiedby FROM ads ORDER BY locationpage, locationarg, locationid, title
I need to arrange the fields as follows:
- sort by link with any fields with the value "all", and the rest in ascending order
- then using locationarg with any null or empty string and then the rest in asc
- then through locationid with any null or 0 values, the rest in asc
- and inside them sort by indicator '1' first, then NULL, then '2'
- and finally, under the heading in ASC, if any of them can be the same
What should my ORDER BY look like?
Here is what I still have: (updated below)
ORDER BY locationpage='all', locationpage ASC, locationarg ASC, locationid ASC, displayorder='1', ISNULL(displayorder), displayorder='2', title ASC
... but it does not work!
source share