日期:2014-05-18  浏览次数:20460 次

求SQL语句,当B列等于某值时,结果不取A列的值
例表:
A列 B列
100 -1
100 21
200 -1

当B列里有21时,不取A列的100

结果:
A列 B列
200 -1

------解决方案--------------------
这问题表达的太不清楚了。难道是这意思?
select * from tb where a not in(select distinct a from tb where b=21)