“where is not null” 语句为什么不起作用???

starrycheng 2015-03-20 04:08:04
select top 2000 BuildingNo, rt.StdCode as Meterusetype, brbhth.LineType,UseType,DADay,DAHour,SumQty,Lable
from BuildingReportByHourTypeH brbhth

left join (select CodeId,StdCode from CodeDetail where CodeGroupNo='MeterUseType') as rt on brbhth.LineType=rt.CodeId
where brbhth.LineType is not null

这里的brbhth.LineType is not null 没起作用啊,查出来的结果集还有为nul来的,怎么回事???


and Lable=0 and UseType in ('EM','WM') and BuildingNo in
( select BuildingNo from Building where UploadFlag=0)
and brbhth.DADay>'20140000' and brbhth.LineType!='All' and brbhth.LineType!='*'
order by DADay asc,DAHour asc


...全文
1451 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
dfm532063923 2015-04-30
  • 打赏
  • 举报
回复
where XXX is not null and XXX=''
---涛声依旧--- 2015-04-29
  • 打赏
  • 举报
回复
建议:以后设置表时,字符型字段最好不允许为空,设置个默认值 ‘’ 尽量避免使用 where 字段 is null 将会逐行扫描的,速度慢
HelloWordGirl 2015-04-29
  • 打赏
  • 举报
回复
where brbhth.LineType !='NULL'
shinger126 2015-04-29
  • 打赏
  • 举报
回复
引用 9 楼 rockyljt 的回复:
建议:以后设置表时,字符型字段最好不允许为空,设置个默认值 ‘’ 尽量避免使用 where 字段 is null 将会逐行扫描的,速度慢
顶!表的设计真的很重要
无涯大者 2015-04-19
  • 打赏
  • 举报
回复
where的时候 IsNULL转化下
hery2002 2015-04-18
  • 打赏
  • 举报
回复
貌似数据问题~
alnce 2015-03-25
  • 打赏
  • 举报
回复
NULL的字段背景色是黄色的,比如你截图中linetype的前一个字段,你问的linetype字段存的是字符串不是NULL
卖水果的net 版主 2015-03-21
  • 打赏
  • 举报
回复
很明显,你的 LineTYpe 中的 NULL ,不是 NULL 而是 "NULL";
hilex_jay 2015-03-20
  • 打赏
  • 举报
回复
是不是以前就存的'NULL'字符串,不是真NULL
江南小鱼 2015-03-20
  • 打赏
  • 举报
回复
改成

isnull(brbhth.LineType,'') <> '' 
还在加载中灬 2015-03-20
  • 打赏
  • 举报
回复
你那个貌似是字符串"NULL",貌似不是空值NULL 你可以试着加上条件 AND Brbhth.LineType<>'NULL'

34,874

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧