Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
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.
Hi All, I am facing a filter data issue,to avoid duplicates query. SELECTErrorList.ErrorMessage ,ErrorList.FilePath ,ErrorList.ErrorStatus ,ErrorList.Browser ,ErrorList.Referer FROM ErrorList inner join(SELECT MAX(errorlistid)AS idFROM errorlist GROUP BY ErrorMessage,filepath,ErrorStatus)DistinctSetON ErrorList.errorlistid=DistinctSet.idORDER 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 pointErrorMessage 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:-
SELECTErrorList.ErrorMessage ,ErrorList.FilePath ,ErrorList.ErrorStatus ,ErrorList.Browser ,ErrorList.Referer FROM ErrorList inner join(SELECT MAX(errorlistid)AS idFROM errorlist GROUP BY STUFF(ErrorMessage,CHARINDEX('(',ErrorMessage),(CHARINDEX(')',ErrorMessage)-CHARINDEX('(',ErrorMessage))+1,''),filepath,ErrorStatus)DistinctSetON ErrorList.errorlistid=DistinctSet.idORDER BY ErrorList.ErrorMessage
soorajtnpki
Posting Yak Master
231 Posts
Posted - 2008-10-25 : 03:55:05
hi visakh , very thanks for ur sudden reply.
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.