Order without Order by

  • vinu512 (7/30/2012)


    GilaMonster (7/30/2012)


    Try adding this as a column, and see if it orders 'correctly'. If so, try select into and see if it's still ordered 'correctly'

    ROW_NUMBER() OVER (ORDER BY (SELECT 1)) As PseudoOrder

    Yes, Exactly.

    That's what I've been saying.

    Nope, what you're saying and what I'm suggesting are not the same thing

    ROW_NUMBER() OVER (ORDER BY (SELECT 1)) As PseudoOrder

    vs

    RowNumber() Over (Order By a.Report_Menu_Code)

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • GilaMonster (7/30/2012)


    vinu512 (7/30/2012)


    GilaMonster (7/30/2012)


    Try adding this as a column, and see if it orders 'correctly'. If so, try select into and see if it's still ordered 'correctly'

    ROW_NUMBER() OVER (ORDER BY (SELECT 1)) As PseudoOrder

    Yes, Exactly.

    That's what I've been saying.

    Nope, what you're saying and what I'm suggesting are not the same thing

    ROW_NUMBER() OVER (ORDER BY (SELECT 1)) As PseudoOrder

    vs

    RowNumber() Over (Order By a.Report_Menu_Code)

    Oh yes....they aren't....I just jumped on seeing the Row_Number() and didn't read the whole query. I am suggesting that the OP can Order the data according to whichever column he wants and then add the Row_Number().

    Vinu Vijayan

    For better and faster solutions please check..."How to post data/code on a forum to get the best help" - Jeff Moden[/url] 😉

  • vinu512 (7/30/2012)


    I am suggesting that the OP can Order the data according to whichever column he wants and then add the Row_Number().

    If he had a column to order by, that would be the obvious solution and wouldn't even need a row number. Problem is, he doesn't.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass

Viewing 3 posts - 16 through 17 (of 17 total)

You must be logged in to reply to this topic. Login to reply