Movatterモバイル変換


[0]ホーム

URL:


Translate:
  • Follow Us

  • Pages

  • Find a Job
  • DFP-300×250-1

  • Newsletter Subscription

      Email

      Country


    • Jobboard

    • In SQL, what is the default sort order of the Order By clause?

      By default, the order by statement will sort inascending order if no order (whether ascending or descending) is explicitly specified. This means that because the default sort order is ascending, the values will be sorted starting from the “smallest” value to the largest. This is true in all major RDBMS’s – including MySQL, Oracle, Microsoft SQL Server, Teradata, SAP, and others.

      An example showing the Order By default sort order:

      Take a look at the simple table below.

      Customers
      cust_idcust_name
      79Joe
      32Bill
      87Akash
      14Sam

      Now, let’s write some SQL to retrieve the cust_name values sorted by their respective cust_id’s, but note that we do not specify whether to sort by descending or ascending order:

      select cust_nameFROM CustomersORDER BY cust_id

      Because the order by will work inascending order by default, the SQL above will return the following results:

      cust_nameSam BillJoeAkash

      Now you have seen the default behavior of the Order By clause in SQL – it will sort in ascending order.

      Hiring? Job Hunting? Post a JOB or your RESUME on our JOB BOARD >>

      Subscribe to our newsletter for more free interview questions.

      Follow @programmerintvw
      Previous...
      Next...

      Would you like to thankProgrammerInterview.com for being a helpful free resource?Then why not tell a friend about us, orsimply add a link to this page from your webpage using the HTML below.

      Link to this page:

      Please bookmark with social media, your votes are noticed and appreciated:


      [8]ページ先頭

      ©2009-2025 Movatter.jp