SELECT sge_job.j_owner AS "Owner"
,SUM(sge_job_usage.ju_cpu) AS "CPU Total"
FROM sge_job_usage, sge_job
GROUP BY j_owner;
这是我当前的SQL查询,只简单地读取CPU%和作业所有者,但我在尝试将仅对在当前日期之前14天(2周)内的总和进行合并时遇到了问题。
在表中,包括:
ju_start_time
,ju_end_time
请帮助我找到如何检查它是否在当前日期- 14天之间,并检查end_time
日期是否仍在运行?以下是输出我需要的答案:
SELECT sge_job.j_owner AS "Owner"
,SUM(sge_job_usage.ju_cpu) AS "CPU Total"
FROM sge_job_usage, sge_job
WHERE ju_start_time BETWEEN LOCALTIMESTAMP - INTERVAL '1 week' AND LOCALTIMESTAMP
GROUP BY j_owner;