May 30, 2007

Quick Tip: Order By 1 Desc

Did you know that instead of specifying the name or column alias in a SQL Server Order By expression you can optionally use an integer representing the position of the column name or alias within the select list you want to sort by.   So both of these queries return the same result set ...-- find me the last 10 log entries select top 10 * from adventureworks.dbo.databaselog order by databaselogid desc -- find me the last 10 log entries select top 10 * from adventureworks.dbo.databaselog order by 1 desc .csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, "Courier New", courier, monospace; background-color: #ffffff; /*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; }...

Comments (1) | TrackBacks (1)

This Blog

  • Email Me
  • RSS
  • Atom
  • Entries - 102
  • Comments - 1276
  • Recent Comments

    • Chau wrote: Matt, I know its wrong to ask? Do you have black and gray version of the images? If would really h...
    • thombcoroemar wrote: Hi. Very interesting site! Thanks!...
    • ntulip wrote: i've followed your example and it seems that it doesn't work when your controls which expose the met...
    • Dave wrote: Anyone figure out the masterpage issue?...
    • rayzal wrote: Nice! i like it so much. Anybody here knows how to do it in PHP? Really appreciate any help :) thnks...
    • vitta wrote: Hi Matt.. I have the smillar requirement on navigating tabs on previous and next buttons. But I am...
    • Kabir wrote: Hi Matt I have been trying to implement this modal edit interface and i have been able to successful...
    • Gustavo Camps wrote: Excellent Blog!!!! is it possible to add Keyboard Navigation funcionality to vs2008 Lisview?...