日期:2014-05-18 浏览次数:20510 次
--上面的数据特殊,改一下 declare @a table(riqi smalldatetime, area varchar(10), info varchar(10)) insert @a select '2007-10-6', '南京', '房价' union all select '2007-10-6' ,'上海', '猪肉' union all select '2007-10-8' ,'西安', '工资' union all select '2007-10-8' ,'南京', '交通' union all select '2007-10-8' ,'上海', '美女' union all select '2007-10-9' ,'上海', '美女' select area from @a a where riqi<'2007-10-31' group by area having(count(1)=(select distinct count(distinct riqi) from @a where riqi<'2007-10-31')) --result /* area ---------- 上海 (所影响的行数为 1 行) */