[dba-SQLServer] sorting by priority then by date?

Gustav Brock Gustav at cactus.dk
Thu Feb 9 11:32:43 CST 2012


Hi Francisco

You could order by first 
  Abs(Priority = "01") DESC
then by the date string.

/gustav

>>> fhtapia at gmail.com 09-02-2012 18:17 >>>
I have a non-access/vb question but more of a logic question... in the
current reporting tool we are using at work I have a requirement to sort a
report by priority then by date...

Priority - Date
01 - 20120115
01 - 20120131
01 - 20120201
------------------------this is where the logic switches to sort by date asc
99 - 20110101
99 - 20110714
99 - 20110815
02 - 20111220
07 - 20120116
90 - 20120201
05 - 20120205


I know it's two queries and in SQL I can create a union query that gives me
what I want, but I am using a different tool and I think the easiest for
that tool is to create a combo unit of priority and date, the result would
be a KEY/DATE combo that would sort in the manner described above...





-Francisco
http://bit.ly/sqlthis   | Tsql and More...
<http://db.tt/JeXURAx>





More information about the dba-SQLServer mailing list