FUNDFAMILY_ID FUND_NAME REPORTSECTION_ID
--------------------------------------------------------------
172295295 VANGUARD GROWTH FUND (Retail) 126345
172295295 VANGUARD GROWTH FUND (Retail) 126354
--------------------------------------------------------------
But i need to get the results like below:
FUNDFAMILY_ID FUND_NAME REPORTSECTION_ID
--------------------------------------------------------------
172295295 VANGUARD GROWTH FUND (Retail) 126345
Inside a stored procedure i have a query like below which gives duplicate rows
INSERT INTO #TABLE_REPORTSECTIONDATA (FUND_NAME, FUNDFAMILY_ID, REPORTSECTION_ID)
SELECT DISTINCT @FUNDNAME_TEMP , @FUNDID_TEMP, EntryPointViewsId
FROM EntryPointViews EPV
ORDER BY EntryPointViewsId
DISTINCT keyword is not giving me the correct results.please suggest
DISTINCT is giving you the correct result, the records are distinct by all columns you have specified. What do you want instead? Just unique according to the ID and the Description? Which
AnotherID
want to take from each group?If you just want an arbitrary you can use
MIN
orMAX
withGROUP BY
: