Query Info
This query provides you with a short overview of information about a certain query. Use this to keep an eye on your top queries.
You will have to set the query name via the macro parameters. Depending on your input the query will be displayed differently.
Query
SELECT QUERY_NAME,
COUNT(ID) AS VIEWS_TOTAL,
MAX(DATE) AS LAST_VIEWED,
MIN(DATE) AS FIRST_VIEWED,
(SELECT COUNT(ID)
FROM AO_AD3311_MACRO_USAGE
WHERE QUERY_NAME = :name
AND DATE >= DATE_ADD(CURDATE(), INTERVAL -30 DAY)) "VIEWS_LAST_MONTH",
(SELECT COUNT(ID)
FROM AO_AD3311_MACRO_USAGE
WHERE QUERY_NAME = :name
AND DATE >= DATE_ADD(CURDATE(), INTERVAL -1 DAY)) "VIEWS_TODAY"
FROM AO_AD3311_MACRO_USAGE
WHERE QUERY_NAME = :name
ORDER BY DATE desc
Note that this query is MySQL specific since it is using DATE functions. If you are using another kind of database you will probably need to adjust the SQL.
TIP: Enable the macro option "dynamic parameters" as well as "use change params template" to quickly and easily look up different queries.