Link to home
Start Free TrialLog in
Avatar of Medrise
Medrise

asked on

SQL DISTINCT not working

I have a query that I'm added ROW_NUMBER() to it, but when I try to add DISTINCT or GROUP BY it does not work.

Here is the query.

SELECT * FROM (SELECT ROW_NUMBER() OVER (ORDER BY fpacode) AS Rownumber, fpaCode, listname, fpaID, emailTo, status, cfid FROM fpaBasket WHERE cfid = 'D1W12978461') AS Sample WHERE Rownumber < 11

Open in new window

Avatar of Medrise
Medrise

ASKER

I need to group all fpaCode
SOLUTION
Avatar of Jim Horn
Jim Horn
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Medrise

ASKER

I want to add the ROW_NUMBER to this query, so should do a SELECT with ROW_NUMBER() with this query?

SELECT DISTINCT(fpaCode), listname, fpaID, emailTo, status, cfid FROM fpaBasket WHERE cfid = 'D1W12978461'

Open in new window

SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Medrise

ASKER

I can return ROWNUMBER 4 that would be fine...
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Can you provide some sample data and your expected output?
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial