結果行3と行4を1行レコードに結合できますか?等(ストアプロシージャ)結果を2行と1行の結果にまとめる
select @fYear as [Year],
(case when main.Description in ('Kecil', 'Tanah') then 'JK'
else main.Description
end) as description,
--CardType,
sum(case when MONTH(blue.AppliedDate) = 1 then 1 else 0 end) as Jan_Collection,
sum(case when MONTH(blue.AppliedDate) = 2 then 1 else 0 end) as Feb_Collection,
...
from tblR as main
left join tblP as b on main.requestorid = b.requestorid
left join tblB as blue on b.partyid = blue.partyid and YEAR(blue.AppliedDate) = @fYear
group by (case when main.Description in ('Kecil', 'Tanah') then 'JK'
else main.Description
end)
この出力: https://gyazo.com/d930cb2aee92f90ba31dd543d6ca64f3
しかし、私は、この絵のようなJKのような1つのレコードに、レコードの行3と4を組み合わせて表示することができる:https://gyazo.com/a89ed2fa04b51135bf8601d59d4af0b2
おかげ。あなたがそれらの特定のdescriptions
を結合したい場合は
は、そのグループの背後にはロジックがありません。それとも少なくとも私はそれを見ることができません –