SELECT
recordtime,
NewCollect=ISNULL(SUM(CASE Type2 WHEN 1 THEN newcnt END),0),
CancelCollect=ISNULL(SUM(CASE Type2 WHEN 1 THEN cancelcnt END),0),
NewKeyword=ISNULL(SUM(CASE Type2 WHEN 2 THEN newcnt end),0),
CancelKeyword=ISNULL(SUM(CASE Type2 WHEN 2 THEN cancelcnt END),0),
NewBlink=ISNULL(SUM(CASE Type2 WHEN 3 THEN newcnt end),0),
CancelBlink=ISNULL(SUM(CASE Type2 WHEN 3 THEN cancelcnt END),0)
FROM B_Com
WHERE 1=1 {0}
GROUP BY recordtime
ORDER BY recordtime DESC