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
 SQL Server Development (2000)
 Query

Author  Topic 

JTProg
Starting Member

24 Posts

Posted - 2007-01-19 : 09:24:28
I have an database where I am trapping erros. I want to be able to find the errors that occurr most frequently for particular users so we can perform additional training. How can I compare strings in a query?

Example:
Wrong Stock
Wrong Stock
Complete Mismatch
Not an allowable value

I want the most common error to be returned as Wrong Stock.
Query so far:
SELECT Max(ErrorDescription)
FROM dbo.tblErrorReport
WHERE PreparedBy = 'Christine'
Order by ErrorDescription ASC

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-01-19 : 09:37:33
select errordescription, count(*)
from tblErrorReport
where preparedby = 'christine'
group by errordescription
order by 2 desc, errordescription


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-01-19 : 09:38:00
You can throw in a TOP 1 or a TOP 1 WITH TIES if you want to.


Peter Larsson
Helsingborg, Sweden
Go to Top of Page
   

- Advertisement -