奔腾年代

但行好事,莫问前程。

导航

sql行转列查询

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

posted on 2012-04-18 14:29  奔腾年代  阅读(150)  评论(0编辑  收藏  举报