Recently I was working one of the select query, wherein I wanted to sort the rows based on latest date and time which are stored in different columns. The requirement by client was that the time will be custom, so I cannot use the DateTime together.
Now I have 2 questions:
It was not sorting until I made the changes in order by clause. my original order by clause was:
ORDER BY PublishDate, PublishTime DESCThe above query was working fine, but was only sorting the
PublishDate, and doing nothing withPublishTime, I understand that it will primarily sort on the basis ofPublishDate, and would give second preference toPublishTime, but with the above query it wasn't giving any preference toPublishTime, but when I changed the order by clause to below it worked fine:ORDER BY PublishDate DESC, PublishTime DESCCan anyone tell me what's the difference between the two queries? Why don't both give primary preference to
PublishDateand secondary toPublishTime?Is it possible to append the custom time to a
DateTimecolumn, I mean say for example if users added a row on31 March 2012, and entered4:00PM, is it possible to add the custom time to the the current date retrieved usingGETDATE()