- SQL code
select count( distinct imsi) from( select *,rank() over (partition by Imsi order by MTime desc) idx from OutDesc7Day_20120117 with(nolock) where MTime<'2012-01-17 13:00' )t left join TourProvinceCity c on convert(varchar(20),t .VlrNum) = c.VlrNum where idx=1 and left( convert(varchar(20),t.VlrNum),5) in('19861') select count( distinct imsi) from( select *,rank() over (partition by Imsi order by MTime desc) idx from OutDesc7Day_20120117 with(nolock) where MTime<'2012-01-17 13:00' )t left join TourProvinceCity c on convert(varchar(20),t .VlrNum) = c.VlrNum where idx=1 and City<>'广州' and left( convert(varchar(20),t.VlrNum),5) in('19861') select count( distinct imsi) from( select *,rank() over (partition by Imsi order by MTime desc) idx from OutDesc7Day_20120117 with(nolock) where MTime<'2012-01-17 13:00' )t left join TourProvinceCity c on convert(varchar(20),t .VlrNum) = c.VlrNum where idx=1 and City='广州' and left( convert(varchar(20),t.VlrNum),5) in('19861')
得出的结果分别是:72540,72329,0
竟然没有等于广州的数据,那么 City<>'广州' 与 没有这个条件应该是一致才对,但是结果却不是。
这是bug 吗?
------解决方案--------------------
null呢?
------解决方案--------------------
可能city有null
这个条件改一下
isnull(City,'')<>'广州'
------解决方案--------------------
除非你的City列不空,这怎么是bug呢?
City<>'广州' 你这个条件肯定取不出City为null的值呀,另一个你更取不出来
------解决方案--------------------
围观一下
------解决方案--------------------
学习了...
------解决方案--------------------
MARK明天看~
------解决方案--------------------
楼主,你哪来的IMSI?不是运营商你保留用户IMSI信息不怕法律风险?
------解决方案--------------------
------解决方案--------------------
应该是有null值的问题,过滤掉
isnull(city,'')<>'广州'
------解决方案--------------------
- SQL code
where City is not null --可以把null的都去掉再比较