hilthunters.blogg.se

Postgresql select distinct
Postgresql select distinct







postgresql select distinct

So, in this case, the statement will return distinct rows for FirstName and LastName.

  • Or are the duplicates removed, and then the items sorted and the top ten items displayed?īefore we answer this question keep in mind that DISTINCT operates on all columns and expressions in the SELECT clause.
  • Is the table sorted by LastName and the top ten items taken, and then duplicate name removed?.
  • TOP 10 will return the first ten items from the ordered set, and SQL DISTINCT will remove any duplicates.

    postgresql select distinct

    SELECT DISTINCT TOP 10 FirstName, LastName FROM Person.Person ORDER BY LastName Let’s look at the first statement who purpose is to return a unique list of fist and last names. I thought everyone would like to know the answer so I create a blog post. What about Select Distinct TOP 10 LastName, FirstName + ' ' + LastName AS FullName FROM Person.Person ORDER BY LastName Is this looking at distinct first names? Distinct combined first and last names? How do we distinguish between the columns used for the distinct evaluation and columns we just want to show in the output? For example, SELECT DISTINCT TOP 10 FirstName, LastName FROM Person.Person ORDER BY LastName I’m a bit confused about SELECT DISTINCT and SELECT. Here is the question that Nan originally sent me:

    postgresql select distinct

    How do the SQL Top and Distinct SELECT modifiers Work Together to Produce Results? Nan’s Original Question You can get started using these free tools using my Guide Getting Started Using SQL Server.

    #Postgresql select distinct series#

    This article is inspired by a series of questions that one of my readers, Nan, recently sent me regarding SQL DISTINCT, TOP, and ORDER BY.Īll the examples for this lesson are based on Microsoft SQL Server Management Studio and the AdventureWorks2012 database.









    Postgresql select distinct