數(shù)據(jù)庫(kù)顯示的頁(yè)面 頁(yè)面顯示的數(shù)據(jù) 說明:頁(yè)面中顯示的表頭是數(shù)據(jù)庫(kù)中表的reson列里面的所有數(shù)據(jù),是固定的,amount是數(shù)量。頁(yè)面中顯示的數(shù)據(jù)是按天數(shù)來(lái)查的,如果該天查到的reason原因中,有些reason原因不存在的話就用0表示。請(qǐng)教各位大俠們:我要做成這種形式的,在數(shù)據(jù)層和服務(wù)端中我應(yīng)該怎么操作,具體應(yīng)該怎么去寫。
1 回答

楊魅力
TA貢獻(xiàn)1811條經(jīng)驗(yàn) 獲得超6個(gè)贊
你的第一個(gè)圖是 是數(shù)據(jù)庫(kù)的原始數(shù)據(jù) 還是你寫查詢語(yǔ)句進(jìn)行的處理過的數(shù)據(jù) 如聚合函數(shù)?
如果數(shù)據(jù)庫(kù)表的數(shù)據(jù)是這樣的話 下面的sql語(yǔ)句
select showtime,isnull(sum(unknow),0) as unknow ,isnull(sum(noidea),0) as noidea , isnull(sum(soso),0) as soso,isnull(sum(understand),0) as understand from (select showtime,case when reason='不明白' then Amount end unknow, case when reason='不清楚' then Amount end noidea, case when reason='還好' then Amount end soso, case when reason='了解' then Amount end understand from test1 group by showtime,reason,Amount) as temp group by showtime --表test1 你可以替換為 你的查詢語(yǔ)句
查詢結(jié)果
showtime unknow noidea soso understand ----------------------- ----------- ----------- ----------- ----------- 2012-01-12 00:00:00.000 0 0 5 4 2012-02-10 00:00:00.000 3 0 0 0 2012-11-18 00:00:00.000 2 3 0 3 2012-12-21 00:00:00.000 0 1 0 0
你應(yīng)該把的表結(jié)構(gòu) 給說出來(lái) 而不是你查出來(lái)的數(shù)據(jù) 我還糾結(jié)哪有這樣建表的啊
- 1 回答
- 0 關(guān)注
- 620 瀏覽
添加回答
舉報(bào)
0/150
提交
取消