日期:2014-05-19  浏览次数:20505 次

求一条语句,请高手指点!TKS!(分有限)
有表Tb,其字段如下:
            A                     B
            null             ynb01
            BY001           ynb01
            Bg003           ysp04
            Bg004           ysp04
怎么才能选择出B字段内值所对应的A内即有“null”又有与“null”不一样的值?
不知用游标该怎么写?

------解决方案--------------------
select * from Tb where B in (select B from Tb where A is null)
and B in (select B from Tb where A is not null)
------解决方案--------------------
try


Select * From Tb Where B In (Select B From Tb Group By B Having Count(Distinct A) > = 2)