Select distinct values from 1 column

后端 未结 9 2109
忘了有多久
忘了有多久 2020-12-10 00:47

I want to select distinct values from only one column (the BoekingPlaatsId column) with this query:

SELECT MAX(BoekingPlaatsId), BewonerId, Naam, VoorNaam
F         


        
9条回答
  •  庸人自扰
    2020-12-10 01:44

    DISTINCT should work if you just want the user names:

    SELECT DISTINCT BewonerId, Naam, Voornaam
    FROM TBL
    

    but if you need the minimum ID values, group by the names...

    SELECT MIN(BoekingPlaatsId), MIN(BewonerId), Naam, Voornaam
    FROM TBL
    GROUP BY Naam, Voornaam
    

提交回复
热议问题