select sum(je) from t_jetj
where areaid like '1%' and phonenum not like
(select phonenum from t_phonenum where num like '1%' )+'%'求指教,上面伪SQL该怎么改
where areaid like '1%' and phonenum not like
(select phonenum from t_phonenum where num like '1%' )+'%'求指教,上面伪SQL该怎么改
where areaid like ''1%''
and phonenum not like '''+@x+'%'' 'exec(@tsql)
SELECT SUM(je)
FROM t_jetj AS A WITH(NOLOCK) INNER JOIN
t_phonenum AS B WITH(NOLOCK) ON A.phonenum NOT LIKE B.phonenum+'%'
AND A.areaid LIKE '1%'
AND B.num LIKE '1%'改成这样试试。
where areaid like '1%' and phonenum not like (phonenum+'%')
你试试,我没有数据,所以不知道可以不?
from t_jetj a
left join (select phonenum from t_phonenum where num like '1%' ) t on t.phonenum=left(a.phonenum,len(rtrim(t.phonenum)))
where areaid like '1%' and t.phonenum is null