我現在有一個SQL查詢,看起來像這樣每個日期:SQL查詢範圍
SELECT CONVERT(DECIMAL(5,1),(
CONVERT(DECIMAL(6,1),(
SELECT COUNT(*)
FROM Requests
LEFT JOIN RequestSLA ON Requests.RequestId = RequestSLA.RequestId
WHERE DateLogged between '2015/03/01' and '2015/08/17'
AND RespondBy <= Responded
))/CONVERT(DECIMAL(6,1),(
SELECT COUNT(*)
FROM Requests
WHERE DateLogged between '2015/03/01' and '2015/08/17'
)))
*100)
這將返回票是違反了迴應SLA(這裏是RespondBy之後有反應)的所有門票的百分比在提供的日期範圍內。是否可以修改此查詢以分別顯示每天的百分比? I.E.是這樣的:
Date Percentage
2015-03-01 10
2015-03-02 7
等等
我試圖用一個GROUP BY
條款,但這並沒有工作,因爲DateLogged(這是什麼,我會通過被分組)不包括在聲明
爲什麼兩個'CONVERT()'? – Barranka