SELECT
a.id id,
a.gmt_create gmtCreate,
a.gmt_modified gmtModified,
a.app_id appId,
a.app_name appName,
a.dept_no deptNo,
a.dept_name deptName,
a.aone_product_id aoneProductId,
a.aone_product_name aoneProductName,
a.app_score appScore,
a.line_count lineCount,
a.complexity complexity,
a.duplication duplication,
a.comment_rate commentRate,
a.ut_rate utRate,
a.ui_rate uiRate,
a.it_rate itRate,
a.static_code_check_value1 staticCodeCheckValue1,
a.static_code_check_value2 staticCodeCheckValue2,
a.static_code_check_value3 staticCodeCheckValue3,
a.date_stamp dateStamp,
a.deviation deviation,
b.app_score appScoreRelative,
b.complexity complexityRelative,
b.duplication duplicationRelative,
b.comment_rate commentRateRelative,
b.ut_rate utRateRelative,
b.ui_rate uiRateRelative,
b.it_rate itRateRelative,
b.static_code_check_value1 staticCodeCheckValue1Relative,
b.static_code_check_value2 staticCodeCheckValue2Relative,
b.static_code_check_value3 staticCodeCheckValue3Relative
FROM quality_data_of_app a
join quality_data_of_app b
on a.app_id = b.app_id
where a.date_stamp =
(SELECT date(date_stamp) FROM quality_data_of_app
group by date(date_stamp)
order by date(date_stamp) desc limit 1) and
b.date_stamp =
(SELECT date_add(date(date_stamp), interval -30 day) FROM quality_data_of_app
group by date(date_stamp)
order by date(date_stamp) desc limit 1) and
a.dept_name like concat( #{deptName}, '%') and
a.aone_product_id = #{aoneProductId};