blossompark
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!!!!!!
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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_Organizat ion ,
Assignee_Support_Group_Nam e ,
Change_Assignee
no error message now
but returning duplicate rows...
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_Organizat
Assignee_Support_Group_Nam
Change_Assignee
no error message now
but returning duplicate rows...
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
is there some way to remove duplicate rows based on a single column?
for example the CHANGE_ID column
for example the CHANGE_ID column
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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
ASKER
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