Sales puzzle

  • Comments posted to this topic are about the item Sales puzzle

    --------------------------------------
    ;-)β€œEverything has beauty, but not everyone sees it.” ― Confucius

  • Ah! Very simple question to start the day. Thanks Gary:-)

    ~ Lokesh Vij


    Guidelines for quicker answers on T-SQL question[/url]
    Guidelines for answers on Performance questions

    Link to my Blog Post --> www.SQLPathy.com[/url]

    Follow me @Twitter

  • Lokesh Vij (8/13/2013)


    Ah! Very simple question to start the day. Thanks Gary:-)

    +1 πŸ™‚

    _______________________________________________________________
    To get quick answer follow this link:
    http://www.sqlservercentral.com/articles/Best+Practices/61537/

  • kapil_kk (8/13/2013)


    Lokesh Vij (8/13/2013)


    Ah! Very simple question to start the day. Thanks Gary:-)

    +1 πŸ™‚

    +1:-)

    Thanks
    Vinay Kumar
    -----------------------------------------------------------------
    Keep Learning - Keep Growing !!!

  • This was removed by the editor as SPAM

  • Thanx 4 the easy question πŸ™‚

    Thanks & Best Regards,
    Hany Helmy
    SQL Server Database Consultant

  • I have worked with SQL Server on and off for many years, but I don't think I recall ever seeing "ORDER BY [number]" as it appears in this question.

    Could some kindly person explain this to me, because a clear explanation seems to be difficult to locate in the documentation, and in searches. This little issue was why I failed this question!

    Many thanks

    Kenneth Spencer

    You never know: reading my book: "All about your computer" might just tell you something you never knew!
    lulu.com/kaspencer

  • kaspencer (8/14/2013)


    I have worked with SQL Server on and off for many years, but I don't think I recall ever seeing "ORDER BY [number]" as it appears in this question.

    Could some kindly person explain this to me, because a clear explanation seems to be difficult to locate in the documentation, and in searches. This little issue was why I failed this question!

    Many thanks

    Kenneth Spencer

    Order by [some number], this number indicates the order of the column in the Select clause.

    Hope that would help you.

    Thanks & Best Regards,
    Hany Helmy
    SQL Server Database Consultant

  • hany.helmy (8/14/2013)


    kaspencer (8/14/2013)


    I have worked with SQL Server on and off for many years, but I don't think I recall ever seeing "ORDER BY [number]" as it appears in this question.

    Could some kindly person explain this to me, because a clear explanation seems to be difficult to locate in the documentation, and in searches. This little issue was why I failed this question!

    Many thanks

    Kenneth Spencer

    Order by [some number], this number indicates the order of the column in the Select clause.

    Hope that would help you.

    Like for example:

    Select EmpId, EmpName, DeptId, DeptName

    From SomeTable

    Order by 2 -- this indicates that the result set will be sorted by column no. 2 in the Select clause which is 'EmpName'.

    Regards,

    Hany Helmy

    Thanks & Best Regards,
    Hany Helmy
    SQL Server Database Consultant

  • kaspencer (8/14/2013)


    I have worked with SQL Server on and off for many years, but I don't think I recall ever seeing "ORDER BY [number]" as it appears in this question.

    Could some kindly person explain this to me, because a clear explanation seems to be difficult to locate in the documentation, and in searches. This little issue was why I failed this question!

    Many thanks

    Kenneth Spencer

    Hi kenneth,

    In Order By we can specify integer representing the position of the column in the select list. The result set will be sorted based on the column. For further details pls refer

    http://technet.microsoft.com/en-us/library/ms188385.aspx

    Also FYI, Order By has no effect in this question, without sorting also you will get the same result, Its matter of Where clause.

    I hope you are aware of Where clause will be applied before Order By.

    --
    Dineshbabu
    Desire to learn new things..

  • I use numbers in my order by statements every day for short queries. It is faster than typing out long names and is especially nice when the column is some kind of calculatoni, function or case statement. I would not use them for production systems but for just checking around it my data they have been wonderful

  • Dineshbabu (8/14/2013)


    kaspencer (8/14/2013)


    I have worked with SQL Server on and off for many years, but I don't think I recall ever seeing "ORDER BY [number]" as it appears in this question.

    Could some kindly person explain this to me, because a clear explanation seems to be difficult to locate in the documentation, and in searches. This little issue was why I failed this question!

    Many thanks

    Kenneth Spencer

    Hi kenneth,

    In Order By we can specify integer representing the position of the column in the select list. The result set will be sorted based on the column. For further details pls refer

    http://technet.microsoft.com/en-us/library/ms188385.aspx

    Also FYI, Order By has no effect in this question, without sorting also you will get the same result, Its matter of Where clause.

    I hope you are aware of Where clause will be applied before Order By.

    Nice explanation Dinesh πŸ™‚

    _______________________________________________________________
    To get quick answer follow this link:
    http://www.sqlservercentral.com/articles/Best+Practices/61537/

  • You know, a simpler question is nice every once in a while. In fact, I found myself studying it to see what I missed. πŸ™‚ Thanks.

  • tom.w.brannon (8/14/2013)


    I use numbers in my order by statements every day for short queries. It is faster than typing out long names and is especially nice when the column is some kind of calculatoni, function or case statement. I would not use them for production systems but for just checking around it my data they have been wonderful

    Agree with Tom. We did have this "feature" used in production and it caused issues when an additional column was added to the select causing the "ORDER BY" to bring the records back in an order that was not expected.

    However, as Tom mentioned, this is great when doing sub queries, unions or aggregates to do a quick check on the date without having to define aliases or use the calculation in the order by clause.

    Anton

  • Good question. It's a shame that in my dazed state I knew the right answer, but picked the wrong one. Time to go have some magic caffeinated elixir.



    Everything is awesome!

Viewing 15 posts - 1 through 15 (of 32 total)

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