Wednesday, March 7, 2012

Need a quick hand using ORDER BY with two fields in the same table.

I have a problem with ordering and I am hoping that someone is able to help.

In my table I have two fields, "requestdate" and "sentdate", and when I display the records I would like to sort by BOTH fields. I want to do this so that the full query is in order by date.

I tried:

ORDER BY requestdate, sentdate DESC

But obviously all that does is order by requestdate (which is NULL or a date) and than it will order by sentdate.

Can somebody tell me how to order by both as if they were the same field?

Thanks!What exactly do you mean? Do you want to sort by both dates, both DESC? Then

ORDER BY requestdate DESC,sentdate DESC|||Oops thanks so much Douglas, I must be half asleep this morning.

I missed the first DESC keyword which is why it was not working properly. Thanks again so much!

No comments:

Post a Comment