Movatterモバイル変換


[0]ホーム

URL:


Translate:
  • Follow Us

  • Pages

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

  • Newsletter Subscription

      Email

      Country


    • Jobboard

    • In the table below, how would you retrieve the unique values for the employee_location without using the DISTINCT keyword?

       
      employee
      employee_nameemployee_location
      Joe New York
      Sunil India
      Alex Russia
      Albert Canada
      Jack New York
      Alex Russia

      We can actually accomplish this with the GROUP BY keyword. Here’s what the SQL would look like:

      SELECT employee_location from employee GROUP BY employee_location

      Running this query will return the following results:

      employee_location
      New York
      India
      Russia
      Canada

      So, you can see that the duplicate values for "Russia" and "Canada" are not returned in the results.

      This is a valid alternative to using the DISTINCT keyword. If you need a refresher on the GROUP BY clause, then check out this question:Group By and Having. This question would probably be asked just to see how good you are with coming up with alternative options for SQL queries. Although, it probably doesn’t prove much about your SQL skills.

      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