看板 Database 關於我們 聯絡資訊
各位版友好,目前是用SQL Server的資料庫 因為合併欄位後select出來的結果有部分是null的資料 我的sql語法如下 SELECT resources.deviceName+' 剩餘數量:'+case when ((resources.deviceName=resourceAgenda.name) and (resourceAgenda.qty=0)) then CONVERT (varchar, 0) when ((resources.deviceName=resourceAgenda.name) and(resourceAgenda.qty=1)) then CONVERT (varchar, 1) end AS deviceName //以上把欄位合併一個新的欄位,新欄位名稱是deviceName FROM resources,resourceAgenda WHERE (type = '投影機') AND (attachTo = '' OR attachTo IS NULL) and (resourceAgenda.qty is not null or resourceAgenda.qty<>'') and(resourceAgenda.name is not null or resourceAgenda.name <>'') and(resources.deviceName is not null or resources.deviceName<>'') 這樣出來的結果有些有值但有些空值null 附上顯示結果:http://tinyurl.com/kooe3zp 原本想在WHERE條件把合併的新欄位( deviceName)拿來判斷是否為空 不過當然sql認不得這個新欄位... 要如何把合併的新欄位用sql語法把空資料刪除,保留有資料的就好呢? 謝謝大家 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 114.36.224.207 ※ 編輯: a26732300 來自: 114.36.224.207 (06/06 07:04) ※ 編輯: a26732300 來自: 114.36.224.207 (06/06 07:18) ※ 編輯: a26732300 來自: 114.36.224.207 (06/06 07:21) ※ 編輯: a26732300 來自: 114.36.224.207 (06/06 07:31)
wwillian:having? 06/12 19:50
lbeeon:整個select括號 用槽狀方法寫? 06/13 02:23