Sorting Records

  • colleagues, I have tables similar to the table below and I want to sort the records according to Child_ID in an ascending order without creating a new table.

    Any assistance please

    Child_IDAge (months)Height(cm)sex

    17200134 93.2 M

    27200240 85.2 F

    37200342 90 M

    47200643 . M

    57200535 . F

    67200437 M

    77200741 F

    87200836 F

    97200940 F

    107201042 M

  • SELECT Child_ID,Age (months),Height(cm),sex

    FROM MyTable

    ORDER BY Child_ID;

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP

  • And if you need to you can use ASC or DESC to directly control the sort order of ORDER BY, but ASC, or ascending, is the default behavior.

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

  • Grant Fritchey (2/28/2014)


    And if you need to you can use ASC or DESC to directly control the sort order of ORDER BY, but ASC, or ascending, is the default behavior.

    Thank you, captain MSDN 😛

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP

  • Koen Verbeeck (2/28/2014)


    Grant Fritchey (2/28/2014)


    And if you need to you can use ASC or DESC to directly control the sort order of ORDER BY, but ASC, or ascending, is the default behavior.

    Thank you, captain MSDN 😛

    Ha! I wrote that and then went to MSDN to verify I remembered it correctly.

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

  • Many thanks

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

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