17,086
社区成员
发帖
与我相关
我的任务
分享
select m.prop, m.planid, m.ava_date from t_avail_rate m,
(select b.prop, b.planid from
(select t.prop, t.planid from t_plan_info t where t.prop in ('1050', '1052') and (t.rate_code = 'BAR' or t.rate_code = 'BARB') ) a
left join t_avail_rate b on (a.prop = b.prop and a.planid = b.planid)
where to_char(b.ava_date, 'yyyy-mm-dd') >= '2007-11-01' and to_char(b.ava_date, 'yyyy-mm-dd') <= '2007-11-15'
group by b.prop, b.planid having count(b.ava_date ) < 15
) n
where m.prop = n.prop and m.planid = n.planid
and to_char(m.ava_date, 'yyyy-mm-dd') >= '2007-11-01' and to_char(m.ava_date, 'yyyy-mm-dd') <= '2007-11-15' order by m.prop, m.planid, m.ava_date
--标签括起来吧!