ORDER BY

  • The poster's explanation is an opinion which Shaun happens to agree with.

    β€œWrite the query the simplest way. If through testing it becomes clear that the performance is inadequate, consider alternative query forms.” - Gail Shaw

    For fast, accurate and documented assistance in answering your questions, please read this article.
    Understanding and using APPLY, (I) and (II) Paul White
    Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden

  • Wow! Are the number of QOTD replies getter longer or what :w00t:

    There seem to be a lot of strong personalities here :crazy:

    Glad I'm not a DBA....

    always right, never wrong and what I say goes....

    LOL only joking πŸ˜‰

    Must admit I get slightly miffed if the answer is clearly wrong, but hey, I still learn things. All I have to do is remember compatibility when moving to 2005.

    And remember folks..... no one likes a smart a$$ :hehe:

    Far away is close at hand in the images of elsewhere.
    Anon.

  • works fine in 2000..question not correct..

  • Arun V (4/8/2008)


    works fine in 2000..question not correct..

    Just couldn't let it lie..... πŸ˜‰

    --Shaun

    Hiding under a desk from SSIS Implemenation Work :crazy:

  • Sub QOTD_Threadpost

    for n = 1 to Ubound(PeoplesPatience)

    print "But it works in my environment!"

    print "Have you checked the DB compatibility mode?"

    if instr(weekdayname(weekday(Now)), "y") then

    Shaunpost()

    end if

    threadstring$ = threadstring$ + bloodnockjoke(Rnd)

    loop

    end sub

    Semper in excretia, sumus solum profundum variat

  • majorbloodnock (4/9/2008)


    Sub QOTD_Threadpost

    for n = 1 to Ubound(PeoplesPatience)

    print "But it works in my environment!"

    print "Have you checked the DB compatibility mode?"

    if instr(weekdayname(weekday(Now)), "y") then

    Shaunpost()

    end if

    threadstring$ = threadstring$ + bloodnockjoke(Rnd)

    loop

    end sub

    rofl - dude I concede πŸ˜‰

    Hiding under a desk from SSIS Implemenation Work :crazy:

  • Glad you took it that way, Shaun. When I reread my post, I realised I'd forgotten the smiley. Please take it as read that it was meant to be there.

    Semper in excretia, sumus solum profundum variat

  • majorbloodnock (4/9/2008)


    Glad you took it that way, Shaun. When I reread my post, I realised I'd forgotten the smiley. Please take it as read that it was meant to be there.

    Well I was gonna take you outside and knock major blood out of you but thought hang on 's a joke πŸ˜€

    No I really did laugh out loud. πŸ˜€

    --Shaun

    Hiding under a desk from SSIS Implemenation Work :crazy:

  • works fine in SQL Server 2000

    nothing indicates it's for 2005, so I should get a point. It's the first answer.

    this is now the second one in a row that this has happened to, where the answer was not valid.

    What's going on SSC?

  • I have tried it, and it works in SQLServer2000

  • Yeah. SQL 2000 allows this but will duplicate the start_date column. It will appear as the first column, then also in its original column order.

    Had this query also contained a JOIN, then you likely would get an ambiguous column name. That said, it's almost always a good idea to alias or explicitly reference columns anyway. Avoids problems down the line. πŸ™‚


    Kindest Regards,

    Rick Farris
    nimbussoftware.com

  • Thanks for the reply.

    Doesn't it supported by SQLServer 2005? I don't have SQLServer 2005, so couldn't test it.

    Also somebody need to describe the question completely like environment etc. Otherwise, nobody will rely on the answers provided in the such a reliable website.

    Regards,

    Daljeet

  • sorry your answer is not correct because both are same table so there is no problem to call the column any where in the select statement please try again the same query in your database. I already try your query i didn't get any error, so first option 1 is correct

  • If you use sql server 2000, the query works fine but no correct answer choise is posted. This is because the start_date column will appear twice; i.e. as the first column and in its right place in the table.

  • Ashenafi Zeleke (4/11/2008)


    ... but no correct answer choise is posted. This is because the start_date column will appear twice; ...

    Now, the first answer states

    All columns and all rows from the employee table in descending start_date order, with the start_date as the first column

    Which part of that answer does having a column appear twice contradict? Having any column appear just once is neither a necessary nor sufficient condition to comply with that answer. As I go through each condition of the answer, I can honestly say 'yes'. The fact that start_date appears in the first and another column does not contradict any part of the answer.

    "Is that your car?" "No, it's one of my cars"

Viewing 15 posts - 121 through 135 (of 182 total)

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