Order by Clause

  • why view does not allow order by clause while creating unless there is no top ?

  • Because the client usually dictates what the sorting will be (for a proper seperation of the data and its presentation). No need to sort it twice.

    select ...

    from myview

    where ...

    order by myclientprefferedorder

  • Because storage doesn't imply order. A view is simply an overlay onto storage.

    Just like a table doesn't have an order, a view doesn't. Don't use views to preserve order. Use your queries.

  • sudhakara (12/26/2007)


    why view does not allow order by clause while creating unless there is no top ?

    And that behaviour has changed with the 2005 release. Even though you can add that to the view creation script the order is *NOT* followed unless you order the results from a client query as posted above.

    Cheers,


    * Noel

  • sudhakara (12/26/2007)


    why view does not allow order by clause while creating unless there is no top ?

    FYI http://sqlblog.com/blogs/tibor_karaszi/archive/2007/11/28/sorted-views.aspx


    Madhivanan

    Failing to plan is Planning to fail

Viewing 5 posts - 1 through 4 (of 4 total)

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