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

楊魅力
TA貢獻1811條經(jīng)驗 獲得超6個贊
你的第一個圖是 是數(shù)據(jù)庫的原始數(shù)據(jù) 還是你寫查詢語句進行的處理過的數(shù)據(jù) 如聚合函數(shù)?
如果數(shù)據(jù)庫表的數(shù)據(jù)是這樣的話 下面的sql語句
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 你可以替換為 你的查詢語句
查詢結果
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
你應該把的表結構 給說出來 而不是你查出來的數(shù)據(jù) 我還糾結哪有這樣建表的啊
- 1 回答
- 0 關注
- 610 瀏覽
添加回答
舉報
0/150
提交
取消