SQL Distinct Still returns duplicate values

All,

     I've written the following SQL query and despite the fact that I have DISTINCT in the query, it's still returning duplicate values for Full User Name and Name0 (which is the machine name.).  Can anyone see what i'm doing wrong here?  Please keep in mind i'm still a newbie when it comes to SQL.


SELECT DISTINCT v_R_User.Full_User_Name0, v_GS_LastSoftwareScan.LastScanDate, arp.TimeStamp, sys.Name0
FROM         v_R_System AS sys INNER JOIN
                      v_Add_Remove_Programs AS arp ON sys.ResourceID = arp.ResourceID INNER JOIN
                      v_FullCollectionMembership AS fcm ON sys.ResourceID = fcm.ResourceID INNER JOIN
                      v_GS_LastSoftwareScan ON sys.ResourceID = v_GS_LastSoftwareScan.ResourceID INNER JOIN
                      v_R_User ON sys.User_Name0 = v_R_User.User_Name0
WHERE     (arp.DisplayName0 = 'Microsoft Office Standard 2007') AND (fcm.CollectionID = 'SMS00001') AND (v_GS_LastSoftwareScan.LastScanDate >= DATEADD(dd, - 30, 
                      GETDATE()))
GROUP BY v_R_User.Full_User_Name0, v_GS_LastSoftwareScan.LastScanDate, arp.TimeStamp, sys.Name0

Open in new window

Xeif3rAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ralmadaCommented:
something like this?
SELECT 
	v_R_User.Full_User_Name0, 
	max(v_GS_LastSoftwareScan.LastScanDate), 
	max(arp.TimeStamp), 
	sys.Name0
FROM         v_R_System AS sys 
INNER JOIN v_Add_Remove_Programs AS arp ON sys.ResourceID = arp.ResourceID 
INNER JOIN v_FullCollectionMembership AS fcm ON sys.ResourceID = fcm.ResourceID 
INNER JOIN v_GS_LastSoftwareScan ON sys.ResourceID = v_GS_LastSoftwareScan.ResourceID 
INNER JOIN v_R_User ON sys.User_Name0 = v_R_User.User_Name0

WHERE   (arp.DisplayName0 = 'Microsoft Office Standard 2007') AND 
	(fcm.CollectionID = 'SMS00001') AND 
	(v_GS_LastSoftwareScan.LastScanDate >= DATEADD(dd, - 30, GETDATE()))

GROUP BY v_R_User.Full_User_Name0, sys.Name0

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
gothamiteCommented:
DISTINCT means the distinct of all columns, so you will get duplicates in one column if you have different values in one or more of the other columns. In other words the distinctness is over the combination of all SELECTed columns.
0
Xeif3rAuthor Commented:
Wow!  Perfect!  What was I doing wrong?
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server 2005

From novice to tech pro — start learning today.