Search code examples
logparser

Log Parser: HAVING Wildcards


I have a log parser query that gets the top 200 uris, however I don't want any cs-uri-stem entries that have a dot (.) in them.

This is as close as I've come, but it seems like the wildcards are not acting as I expected:

"SELECT TOP 200 cs-uri-stem, COUNT(*) AS Total INTO \Top200URIs_NoDots.csv 
FROM "\2015-01\U*.log" 
GROUP BY cs-uri-stem 
HAVING cs-uri-stem NOT LIKE '%.%'
ORDER BY Total DESC"

When I run this I get an Error:

... HAVING cs-uri-stem NOT LIKE ''...
Error: Syntax Error: <having-clause>: not a valid <expression>

Why is it ignoring the '%'s and everything between?


Solution

  • HAVING is for filtering group results using aggregate functions on the grouped data. Filtering on the grouped data is more processing-intensive because the grouping must be completed first. In this case, your query will be more optimally performed using a WHERE clause anyway. Also, remember to use %% if this is in a batch file. A single % denotes a batch variable and won't make it to the program's arguments.