我在编写正确的 sql 查询时遇到问题,该查询应按国家和站点选择两个日期之间的最小/最大/平均持续时间(以天为单位)以进行试验。
我的查询:
SELECT v.country as country, v.site as site,
COUNT(*) as N --,
--MAX(list of durations in days between discovered date to repored date on each violation by country and site) as "Maximum",
--MIN(list of durations in days between discovered date to repored date on each violation by country and site) as "Minimum",
--AVG(list of durations in days between discovered date to repored date on each violation by country and site) as "Mean"
FROM violations v
WHERE v.trial_id = 3
GROUP BY ROLLUP (v.country, v.site)
这是我的SQLFIDDLE,其中包含改进注释行所需的数据结构和查询。
请问你能帮帮我吗?