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 2005 Forums
 Transact-SQL (2005)
 A difficult issue with duplicates

Author  Topic 

soorajtnpki
Posting Yak Master

231 Posts

Posted - 2008-10-25 : 03:22:02
Hi All,
I am facing a filter data issue,to avoid duplicates query.

SELECT
ErrorList.ErrorMessage
,ErrorList.FilePath
,ErrorList.ErrorStatus
,ErrorList.Browser
,ErrorList.Referer
FROM ErrorList inner join
(SELECT MAX(errorlistid)AS id
FROM errorlist
GROUP BY ErrorMessage,filepath,ErrorStatus)DistinctSet
ON ErrorList.errorlistid=DistinctSet.id
ORDER BY ErrorList.ErrorMessage

query is working fine.

The above query gives a list of records that are distinct based on ErrorMessage,filepath,ErrorStatus.

But my problem is that, still the recordset is not distinct based on error message column.
i will show the sample example to argue my point

ErrorMessage column
[Macromedia][SQLServer JDBC Driver][SQLServer]Transaction (Process ID 116) was deadlocked. The error occurred on line 447.
[Macromedia][SQLServer JDBC Driver][SQLServer]Transaction (Process ID 117) was deadlocked. The error occurred on line 447.

so there process id is different, so it came as in the result set as two distinct records.
So my issue is tat can we avoid (Process ID 116) text from tat column at the time of group by process..
Is it possible...
If tat is possible i have another condition is tat (Process ID 116) may or may not come as text in tat column.

Thanks in advance..

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-10-25 : 03:50:57
try this out:-
SELECT
ErrorList.ErrorMessage
,ErrorList.FilePath
,ErrorList.ErrorStatus
,ErrorList.Browser
,ErrorList.Referer
FROM ErrorList inner join
(SELECT MAX(errorlistid)AS id
FROM errorlist
GROUP BY STUFF(ErrorMessage,CHARINDEX('(',ErrorMessage),(CHARINDEX(')',ErrorMessage)-CHARINDEX('(',ErrorMessage))+1,'')
,filepath,ErrorStatus)DistinctSet
ON ErrorList.errorlistid=DistinctSet.id
ORDER BY ErrorList.ErrorMessage
Go to Top of Page

soorajtnpki
Posting Yak Master

231 Posts

Posted - 2008-10-25 : 03:55:05
hi visakh ,
very thanks for ur sudden reply.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-10-25 : 04:00:39
quote:
Originally posted by soorajtnpki

hi visakh ,
very thanks for ur sudden reply.


cheers
Go to Top of Page
   

- Advertisement -