作者a26732300 (Hades)
看板Database
标题[SQL ] 合并栏位後如何删除空资料
时间Thu Jun 6 07:02:09 2013
各位版友好,目前是用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)
1F:→ wwillian:having? 06/12 19:50
2F:→ lbeeon:整个select括号 用槽状方法写? 06/13 02:23