我有一个ms访问数据库,其中包含一个名为Events
的表AlarmID | Model | Landscape | Date | EventHandle | EventDescription
EventDescription内容在文本中如下所示:
Host_systemEDGE ma 05 jan, 2015 - 15:33:16 - Server Server1 System Eventlog Event Source = Microsoft-Windows-Eventlog Event Description = [23] The event logging service encountered an e
我想找到唯一的EventDescriptions计数。但Servername(Server Server1)几乎每次都不同。想法是分裂“=”或“= [”字符。并只显示它背后的所有内容,以便计数不会分割日期,时间或服务器文本
首先我尝试了这个:
SELECT COUNT(cd.EventDescription) AS AantalUniekeMeldingen, cd.EventDescription
FROM (SELECT EventDescription, [Date], Eventhandle FROM Events) AS cd
WHERE [Date] BETWEEN #1-1-2014# AND #7-1-2015# AND Eventhandle LIKE 'MONITOR MATCH EVENT%' AND EventDescription LIKE '%[[]%' AND EventDescription LIKE '%[]]%'
GROUP BY cd.EventDescription
ORDER BY COUNT(cd.EventDescription) DESC
试图将其转换为:
SELECT COUNT(cd.EventDesc) AS AantalUniekeMeldingen, cd.EventDesc
FROM (SELECT DISTINCT ab.EventDesc, ab.[Date], ab.Eventhandle FROM (SELECT MID(EventDescription, instr(1," = ")) AS EventDesc, [Date], Eventhandle AS ab FROM Events) AS cd
WHERE [Date] BETWEEN #1-1-2014# AND #7-1-2015# AND Eventhandle LIKE 'MONITOR MATCH EVENT%' AND EventDescription LIKE '%[[]%' AND EventDescription LIKE '%[]]%'
GROUP BY cd.EventDescription
有没有更简单的方法?子串没有用......
结果需要看起来像:
Count | Desc
2 | [1]abcd-abcd..
1 | [2]abd-abd..
不喜欢这样:
Count | Desc
1 | 16:20 [1]abcd-abcd..
1 | 16:02 [1]abcd-abcd..
1 | 13:37 [2]abd-abd..