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

Francisco Tapia fhtapia at gmail.com
Thu Feb 9 12:26:54 CST 2012


Thanks Gustav,  because I'm sorting in a 3rd party reporting system I won't
be able to sort in that manner, but I did discover that I can create a
formula field where I pair off the priority with the date ex: 01-20120209
and sort that way where if the field is priority 01 I keep that value,
otherwise I replace it with a generic 99-20120209 and that sorts just as
expected, I guess I just needed a bit of time to think and write it out...


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




On Thu, Feb 9, 2012 at 09:32, Gustav Brock <Gustav at cactus.dk> wrote:

> 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>
>
>
>
> _______________________________________________
> dba-SQLServer mailing list
> dba-SQLServer at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/dba-sqlserver
> http://www.databaseadvisors.com
>
>


More information about the dba-SQLServer mailing list