我的表结构是:
[Event Time]
[Log Message]
[Hostname]
[Client]
我是否可以获得每条日志消息的唯一主机数量?
我可以使用下面的方法获取每个客户端的每条日志消息的总计数,但我试图获取每条日志消息的唯一主机数
Select sub.*
From (SELECT Count([Event Time]) AS test
,[Log Message]
,[Client]
FROM [Severe_logs].[dbo].[Severe_logs]
Group BY [Client], [Log Message]
)sub
WHERE sub.test > 25
ORDER BY test DESC
我想要的输出是
Count - Log Message - Client
5 log x Client1
6 log x Client 2
我该怎么做?
由于
答案 0 :(得分:1)
您可以使用不同的计数
Select sub.*
From (SELECT Count(distinct hostname) AS test
,[Log Message]
,[Client]
FROM [Severe_logs].[dbo].[Severe_logs]
Group BY [Client], [Log Message]
)sub
WHERE sub.test > 25
ORDER BY test DESC