mybatis时间问题interval
select product_id,survey_date+interval '1 DAYS'
select * from (
select *,
case when last_week_avg_price=0 then 0 else (this_week_avg_price-last_week_avg_price)/last_week_avg_price*100 end ringvalue,
(select sum(cast(this_day_trading as double)) from dr_information_items where good_id=v.good_id and date_week=to_char(to_date(#{surveyDateWeek},'yyyy-MM-dd')+interval '-7 DAYS', 'yyyy-mm-dd') group by good_id,date_week) lastWeekTrading
from
(
SELECT
min(dr.id) id,
items.cateid AS class_code,
min(items.good_name) AS class_name,
min(items.good_id) AS good_id,
min(items.product) AS product,
sum(items.this_day_count_price) AS this_week_price,
sum(cast(items.this_day_trading as double)) AS this_day_trading,
case when sum(cast(items.this_day_trading as double))=0 then avg(items.last_week_avg_price) else sum(items.this_day_count_price)/sum(cast(items.this_day_trading as double)) end this_week_avg_price ,
avg(items.last_week_avg_price) AS last_week_avg_price,
min(items.unit) AS unit,
max(u.user_name) shop_number
FROM dr_information_items items
left JOIN dr_information dr ON dr.id = items.infomationid
left JOIN sys_user u on LTrim(RTrim(items.create_by))=cast(LTrim(RTrim(u.user_name)) as text)
WHERE items.date_week IS NOT NULL AND dr.status =#{status}
<if test="marketId != null and marketId != ''">
and dr.market_id=#{marketId}
</if>
<if test="surveyDateWeek != null">
and to_date(items.date_week,'YYYY-MM-DD')=#{surveyDateWeek}
</if>
GROUP BY items.date_week, items.cateid
) v
) t where 1=1
<if test="classCode != null">
and LEFT(class_code,4)=#{classCode}
</if>
<if test="ringvalue != null">
and ringvalue <![CDATA[ >= ]]> #{ringvalue}
</if>
UNION
select id,class_id class_code,name class_name,'' good_id,'' product,null this_week_price,null this_day_trading,null this_week_avg_price,null last_week_avg_price,'' unit,'' shop_number,null ringvalue,null lastWeekTrading
from dr_lybase_class where LEFT(class_id,4)=#{classCode} and LENGTH(class_id)=8 and LEFT(class_id,8) in (select LEFT(cateid,8) from dr_information_items
where to_date(date_week,'YYYY-MM-DD')=#{surveyDateWeek})
order by class_code