【发布时间】:2022-01-18 02:17:36
【问题描述】:
我正在尝试进行计算,我想根据餐厅是每周 5 天还是 7 天,根据助理和主教练的数量更新理想时间。当我使用 10/7 或 20/7 进行计算时,它分别作为 1 和 2。我目前正在使用 trunc 但我尝试过使用 cast :: decimal(10,6) 等但它不起作用。
select
a.entity,
a.store_name,
a.order_date,
a.daily_ideal_hours,
a.daily_ideal_hours - (case when b.days_open like '%Weekdays%' then ((c.total_acs*(20/5) + c.total_hcs*(10/5)))
when b.days_open like '%All%' then ((c.total_acs * trunc(20/7,10)) + (c.total_hcs * trunc(10/7,10))) end) as updated_value
from scorecards_ideal_labor_hours as a
left join days_store_open as b
on a.entity = b.entity
left join hc_ac_data as c
on a.entity = c.entity_id
and a.order_date = c.report_date
where a.order_date between '2021-12-06' and '2021-12-12'
and a.entity = 66
order by a.order_date desc;
我该如何解决这个问题?
【问题讨论】:
-
使用 7.0 以便它使用浮点计算。
标签: sql amazon-redshift decimal integer-division