Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 GROUP By problem, distinct column

Author  Topic 

mjhjason
Starting Member

6 Posts

Posted - 2011-11-02 : 15:45:45
Trying to add additional output columns to the group by.. But doesn't work. Trying to detect duplicate "subject"'s ..

http://snpr.cm/91mMmG.png

Could anyone assist in detecting duplicates and putting either exclusion, or output just distinct... any help to detect would be good.

Help!

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-11-03 : 04:55:00
sorry that link is not accesible. would you mind posting it here?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

mjhjason
Starting Member

6 Posts

Posted - 2011-11-03 : 12:46:47
Sure thing,


SELECT TOP (100) PERCENT 'Purchasing' AS projectName, dbo.VERSION.FileName, dbo.VERSION.Keywords, dbo.VERSION.Subject, dbo.VERSION.Document_No,
dbo.ACL.Name AS ACLName, dbo.FRP_TABLE.Description AS ACLDesc, dbo.SECURITY.Name AS SecLvl, dbo.VERSION.FileName AS Null_0,
'L:\' + dbo.VERSION.FileName AS fileSee, 'L:\' + dbo.VERSION.FileName AS Existed, dbo.FILES.Prefix_ID, dbo.FILES.File_No
FROM dbo.VERSION INNER JOIN
dbo.FRP_TABLE ON dbo.VERSION.FRP_ID = dbo.FRP_TABLE.FRP_ID INNER JOIN
dbo.FILES ON dbo.FRP_TABLE.FRP_ID = dbo.FILES.FRP_ID INNER JOIN
dbo.ACL ON dbo.VERSION.ACL_ID = dbo.ACL.ACL_ID AND dbo.FILES.ACL_ID = dbo.ACL.ACL_ID INNER JOIN
dbo.SECURITY ON dbo.VERSION.Security_ID = dbo.SECURITY.Security_ID AND dbo.FILES.Security_ID = dbo.SECURITY.Security_ID
WHERE (dbo.FILES.Prefix_ID = 8) AND (dbo.FILES.File_No = '0100-02-01')
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-11-03 : 12:54:56
what according to you are duplicate?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

mjhjason
Starting Member

6 Posts

Posted - 2011-11-03 : 14:17:45
Duplicates are duplicate subject's.. Trying to output the additional columns, but SQL Server Management Studio View Editor wont let me group by SubjecT counts...
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-11-04 : 05:49:49
so when you return 1 row per subject, what should value for other fields? should it be first instance value or last instance value in a group? would be better if you can show what you want by means of sample data

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -