| 发表于:2007-07-21 16:03:004楼 得分:30 |
樓主說的是這個意思? declare @t table( a varchar(10), b int, c int) insert @t select '2007-05-01 ', 30, 5 union all select '2007-06-01 ', 20, 3 union all select '2007-06-12 ', 15, 6 union all select '2007-06-14 ', 30, 2 union all select '2007-06-28 ', 40, 6 union all select '2007-07-03 ', 12, 7 union all select '2007-07-13 ', 53, 3 union all select '2007-07-15 ', 52, 5 select * from @t where a between '2007-06-01 ' and '2007-06-30 ' and exists(select 1 from @t where a between '2007-06-01 ' and '2007-06-30 ' having sum(b) > 50) /* a b c ---------- ----------- ----------- 2007-06-01 20 3 2007-06-12 15 6 2007-06-14 30 2 2007-06-28 40 6 (所影响的行数为 4 行) */ | | |
|