Link to home
Start Free TrialLog in
Avatar of blossompark
blossomparkFlag for Ireland

asked on

DISTINCT keyword not removing duplicate rows in sql server 2005 temp table

Hi,
       I have  a query (see code) that returns a set of rows where there are many duplicates, however using DISTINCT does not remove the duplicates..
any help greatly appreciated!!!!!!
SELECT DISTINCT
Scheduled_Start_Date ,
Scheduled_End_Date ,
Change_ID ,
Summary ,
Notes  ,
PIR ,
Risk_Level ,
IMPACT ,
Region ,
SITE ,
TIMING,
Status ,
Requested_BY_First_Name  ,
Requested_By_Last_Name ,
Assignee_Support_Company ,
Assignee_Support_Organization  ,
Assignee_Support_Group_Name  ,
Change_Assignee  
FROM #FailedTab

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of JRandel
JRandel
Flag of United Kingdom of Great Britain and Northern Ireland 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 blossompark

ASKER

Hi, JRandel
tried
FROM #FailedTab
GROUP BY Change_ID

but doesn't work
----is invalid in the select list because it is not contained in either an aggrgate function or the GROUP BY clause
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
did GROUP BY
Scheduled_Start_Date ,
Scheduled_End_Date ,
Change_ID ,
Summary ,
Notes  ,
PIR ,
Risk_Level ,
IMPACT ,
Region ,
SITE ,
TIMING,
Status ,
Requested_BY_First_Name  ,
Requested_By_Last_Name ,
Assignee_Support_Company ,
Assignee_Support_Organization  ,
Assignee_Support_Group_Name  ,
Change_Assignee  

no error message now
but returning duplicate rows...
SOLUTION
Avatar of Anthony Perkins
Anthony Perkins
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
is there some way to remove duplicate rows based on a single column?
for example the CHANGE_ID column
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
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
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
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
ok....thanks for all your comments....i have found that one of the columns has different data in every row (the PIR) column so therefore the returned rows are not actually duplicates? but are unique? sorry for having only discovered this now..i dont understand why one of the columns would have different values..i think i will have to go back to the "drawing board" on this one....thanks for all your comments, they really help and are thought provoking