이 같은 시작할 수 있습니다 : 그것은 당신이 원하는대로 같은 결과에 대해 제공하지만, 전치
SELECT logTypeId, Count(logTypeId) AS nbTotal, -1 * Sum(isResolved) AS nbTrue, Count(logTypeId) + Sum(isResolved) As nbFalse
FROM TLogging
GROUP BY logTypeId;
.
편집 :하거나, 그것은 추한하지만 난 당신이
SELECT 'True' As Resolved, t0.nb As LogType0, t1.nb As LogType1, t2.nb As LogType2, t3.nb As LogType3, t4.nb As LogType4, t5.nb As LogType5
FROM (Select -1 * Sum(isResolved) As nb From TLogging Where logTypeId = 0) AS t0
, (Select -1 * Sum(isResolved) As nb From TLogging Where logTypeId = 1) AS t1
, (Select -1 * Sum(isResolved) As nb From TLogging Where logTypeId = 2) AS t2
, (Select -1 * Sum(isResolved) As nb From TLogging Where logTypeId = 3) AS t3
, (Select -1 * Sum(isResolved) As nb From TLogging Where logTypeId = 4) AS t4
, (Select -1 * Sum(isResolved) As nb From TLogging Where logTypeId = 5) AS t5
Union All
SELECT 'False' As Resolved, t0.nb As LogType0, t1.nb As LogType1, t2.nb As LogType2, t3.nb As LogType3, t4.nb As LogType4, t5.nb As LogType5
FROM (Select Count(*) + Sum(isResolved) As nb From TLogging Where logTypeId = 0) AS t0
, (Select Count(*) + Sum(isResolved) As nb From TLogging Where logTypeId = 1) AS t1
, (Select Count(*) + Sum(isResolved) As nb From TLogging Where logTypeId = 2) AS t2
, (Select Count(*) + Sum(isResolved) As nb From TLogging Where logTypeId = 3) AS t3
, (Select Count(*) + Sum(isResolved) As nb From TLogging Where logTypeId = 4) AS t4
, (Select Count(*) + Sum(isResolved) As nb From TLogging Where logTypeId = 5) AS t5
Union All
SELECT 'All' As Resolved, t0.nb As LogType0, t1.nb As LogType1, t2.nb As LogType2, t3.nb As LogType3, t4.nb As LogType4, t5.nb As LogType5
FROM (Select Count(*) As nb From TLogging Where logTypeId = 0) AS t0
, (Select Count(*) As nb From TLogging Where logTypeId = 1) AS t1
, (Select Count(*) As nb From TLogging Where logTypeId = 2) AS t2
, (Select Count(*) As nb From TLogging Where logTypeId = 3) AS t3
, (Select Count(*) As nb From TLogging Where logTypeId = 4) AS t4
, (Select Count(*) As nb From TLogging Where logTypeId = 5) AS t5
;
하이 진을 원하는 정확히 결과를 제공합니다 생각합니다. 대답을 주셔서 감사합니다, 그러나 이것은 단순히 모든 것을 여러 컬럼에 집어 넣기 때문에 나의 필요를 충족시키지 못합니다. – cardycakes
어떨까요 (편집 참조)? –
예, 그렇습니다. 고마워. 진. – cardycakes