title: ORDER BY clause in SQL Server
body: <p>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 <code>DateTime</code> together.</p>
  
  <p>Now I have 2 questions:  </p>
  
  <ol>
  <li><p>It was not sorting until I made the changes in order by clause. my original order by clause was:</p>
  
  <pre><code>ORDER BY PublishDate, PublishTime DESC
  </code></pre>
  
  <p>The above query was working fine, but was only sorting the <code>PublishDate</code>, and doing nothing with <code>PublishTime</code>, I understand that it will primarily sort on the basis of <code>PublishDate</code>, and would give second preference to <code>PublishTime</code>, but with the above query it wasn't giving any preference to <code>PublishTime</code>, but when I changed the order by clause to below it worked fine:</p>
  
  <pre><code>ORDER BY PublishDate DESC, PublishTime DESC
  </code></pre>
  
  <p>Can anyone tell me what's the difference between the two queries? Why don't both give primary preference to <code>PublishDate</code> and secondary to <code>PublishTime</code>?</p></li>
  <li><p>Is it possible to append the custom time to a <code>DateTime</code> column, I mean say for example if users added a row on <code>31 March 2012</code>, and entered <code>4:00PM</code>, is it possible to add the custom time to the the current date retrieved using <code>GETDATE()</code> </p></li>
  </ol>