我正在尝试将计算作为一列,但似乎失败了。没有称为间隙的列
这条线是
case d.gap when a.actual_value IS TRUE then (quar_target - a.actual_value) else 'NULL' END ,
整个脚本是
SELECT
weekly.* ,
quarterly.target_value as quar_target
FROM (
SELECT a.week_id,
d.region_id,
d.region_name,
d.metric_id ,
case d.metric_desc
when 'BE GMV Lift' then 'GMV Lift'
when 'B2C GMV Lift' then 'GMV Lift'
when 'Trust GMV Lift' then 'GMV Lift'
else d.metric_desc
end as metric_desc,
case d.gap
when a.actual_value IS TRUE
then (quar_target - a.actual_value)
else 'NULL' END,
d.ini_name ,
a.actual_value ,
a.actual_txt ,
a.target_value ,
a.target_txt ,
a.signals ,
a.comments
FROM
-- Get most recently reported records. If the metric is not reported for this week, get the last reported number
( SELECT *
FROM l1_weekly_entry
WHERE week_id=WEEK(CURDATE(), 1) - 1
) a
我正在尝试介绍一列 d.gap