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 吗?
isnull(City,'')<>'广州'
City<>'广州' 你这个条件肯定取不出City为null的值呀,另一个你更取不出来
City<>'广州' 就 去掉了 null 的情况啦?
isnull(city,'')<>'广州'