I want to select distinct values from only one column (the BoekingPlaatsId column) with this query:
SELECT MAX(BoekingPlaatsId), BewonerId, Naam, VoorNaam
F
This is how you can select from a table with only unique values for your column:
CREATE VIEW [yourSchema].[v_ViewOfYourTable] AS
WITH DistinctBoekingPlaats AS
(
SELECT [BewonerId],
[Naam],
[VoorNaam],
[BoekingPlaatsId],
ROW_NUMBER() OVER(PARTITION BY [BoekingPlaatsId] ORDER BY DESC) AS 'RowNum'
FROM [yourSchema].[v_ViewOfYourTable]
)
SELECT *
FROM DistinctProfileNames
WHERE RowNum = 1
--if you would like to apply group by you can do it in this bottom select clause but you don't need it to gather distinct values
You don't need group by to accomplish this.