close
Tutorials · Query examples

Useful SQL queries to adapt

Confirm provider field names, replace paths and values, then begin with a small TOP limit.

Top IIS status codes

SELECT sc_status, COUNT(*) AS requests
FROM 'C:\inetpub\logs\*.log'
GROUP BY sc_status ORDER BY requests DESC;

Slowest IIS endpoints

SELECT cs_uri_stem, COUNT(*) AS requests,
 AVG(time_taken) AS avg_ms, MAX(time_taken) AS max_ms
FROM 'C:\inetpub\logs\*.log'
GROUP BY cs_uri_stem HAVING COUNT(*) > 20
ORDER BY avg_ms DESC;

Frequent Windows events

SELECT SourceName, EventID, COUNT(*) AS total
FROM System GROUP BY SourceName, EventID
ORDER BY total DESC;

Summarize a CSV export

SELECT status, COUNT(*) AS records, SUM(amount) AS total
FROM 'C:\data\orders.csv'
GROUP BY status ORDER BY total DESC;