亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

數據的顯示情況

數據的顯示情況

森欄 2018-08-02 05:06:13
數據庫顯示的頁面                                           頁面顯示的數據      說明:頁面中顯示的表頭是數據庫中表的reson列里面的所有數據,是固定的,amount是數量。頁面中顯示的數據是按天數來查的,如果該天查到的reason原因中,有些reason原因不存在的話就用0表示。請教各位大俠們:我要做成這種形式的,在數據層和服務端中我應該怎么操作,具體應該怎么去寫。
查看完整描述

1 回答

?
楊魅力

TA貢獻1811條經驗 獲得超6個贊

你的第一個圖是 是數據庫的原始數據   還是你寫查詢語句進行的處理過的數據  如聚合函數?

如果數據庫表的數據是這樣的話 下面的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



你應該把的表結構 給說出來 而不是你查出來的數據 我還糾結哪有這樣建表的啊  


查看完整回答
反對 回復 2018-08-06
  • 1 回答
  • 0 關注
  • 611 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號