【业务影响】
【是否存算分离】否
【StarRocks版本】例如:3.1.3
报错内容是: ERROR 1064 (HY000): invalid field name: cost_tax
查询的sql是:
SELECT cast( date_trunc(‘day’,date(substr(orderdate,1,10))) AS varchar ) AS category
,ordercategory AS dim
,SUM(trip_tickets) AS trip_tickets
,SUM(trip_profit) AS trip_profit
,SUM(trip_profit) * 1.0 / SUM(trip_tickets) AS pre_trip_profit
,SUM(trip_orders) AS trip_orders
,SUM(markup) AS add_price
,SUM(markup) * 1.0 / SUM(trip_tickets) AS pre_cashprofit
,SUM(x_profit) * 1.0 / SUM(trip_tickets) AS pre_x_profit
,SUM(trip_profit) * 1.0 / SUM(price_tax) AS profit_rate
,SUM(markup) * 1.0 / SUM(cost_tax) AS cashprofit_rate
,SUM(cost_notax) AS cost_notax
,SUM(price_tax) * 1.0 / SUM(trip_tickets) AS pre_price_tax
,(SUM(markup) + SUM(x_profit)) * 1.0 / SUM(price_tax) AS take_rate
,SUM(deductionamount) / SUM(price_tax) AS app_tejia_rate
FROM
(
SELECT *
FROM
(
SELECT *
,‘ALL’ AS ordercategory
FROM dw_fltdb.adm_fltinsight_pricingkpi_orderdetail_monitor3
WHERE 1 = 1
AND orderdate BETWEEN ‘2024-07-16’ AND ‘2024-07-22’
UNION ALL
SELECT *
,‘1-Direct’ AS ordercategory
FROM dw_fltdb.adm_fltinsight_pricingkpi_orderdetail_monitor3
WHERE 1 = 1
AND orderdate BETWEEN ‘2024-07-16’ AND ‘2024-07-22’
AND COALESCE(channel, ‘’) <> ‘Direct’
UNION ALL
SELECT *
,‘1-Meta’ AS ordercategory
FROM dw_fltdb.adm_fltinsight_pricingkpi_orderdetail_monitor3
WHERE 1 = 1
AND orderdate BETWEEN ‘2024-07-16’ AND ‘2024-07-22’
AND COALESCE(channel, ‘’) NOT IN (‘SC’, ‘其他Meta’)
UNION ALL
SELECT *
,‘Meta’ AS ordercategory
FROM dw_fltdb.adm_fltinsight_pricingkpi_orderdetail_monitor3
WHERE 1 = 1
AND orderdate BETWEEN ‘2024-07-16’ AND ‘2024-07-22’
AND COALESCE(channel, ‘’) IN (‘SC’, ‘其他Meta’)
) t2
) t1
WHERE 1 = 1
GROUP BY 1
,2
去掉union all 后正常查询