求助!关于2个字段数据的对比
本帖最后由 dickycheng830 于 2012-12-20 10:14:26 编辑
表 as
name rt1 rt2
aa fg6.12 fg6.11
bb fg6.11 fg6.10
cc fg6.12 fg6.12
dd fg6.10 fg6.10
将rt1字段数据和rt2的字段数据进行比较,查看他们是否一致
如果一致返回1,不一致返回0
如
表 as
name yz
aa 0
bb 0
cc 1
dd 1
------解决方案--------------------select name,yz=case when rt1=rt2 then 1 else 0 end from as
------解决方案--------------------select name,case when rt1=rt2 then 1 else 0 end as yz from tablename
------解决方案--------------------select name,case when replace(rt1,' ','')=replace(rt2,' ','') then 1 else 0 end as yz from tablename