SELECT DISTINCT Help
-
I have an SQL 2005 data table that has these coloumn; Name Type EventDate, DateTime WaysideAddress, Nvarchar(50) WaysideName, Nvarchar(50) State, nchar(10) AlarmMessage, Nvarchar(50) What I am trying to do is count the total number of distinct AlarmMessage that each WaysideName reported from the table Grouped by EventDate and WaysideName. The AlarmMessage is all text. So the results of the query should look like this; WaysideName|AlarmMessage|Count Thanks,
-
I have an SQL 2005 data table that has these coloumn; Name Type EventDate, DateTime WaysideAddress, Nvarchar(50) WaysideName, Nvarchar(50) State, nchar(10) AlarmMessage, Nvarchar(50) What I am trying to do is count the total number of distinct AlarmMessage that each WaysideName reported from the table Grouped by EventDate and WaysideName. The AlarmMessage is all text. So the results of the query should look like this; WaysideName|AlarmMessage|Count Thanks,
Solved my own question; SELECT DISTINCT WaysideName, ST, AlarmMessage, COUNT(AlarmMessage) AS Error_Count FROM AlarmsList GROUP BY WaysideName, ST, AlarmMessage ORDER BY Error_Count DESC, ST, WaysideName, AlarmMessage Thanks Everyone regardless!