我有一些这样的代码:
REPLACE INTO digisob_rekap_peruser(
user_rk,
lokasi_lk,
target_lk,
pertarget //2. data does not enter this column ,
vis_lk,
nsb_lk)
SELECT
jadwal_userid,
lokasi_lk,
target_kunjungan*$x,
vis_lk/target_lk*100 AS pertarge //1. this line,
COUNT(jadwal_userid) AS total,
SUM(SJ_Tsel_3_2) AS jualan
FROM
jadwal,
data_kunjungan,
user,
digisob_rekap_peruser
WHERE
数字1有结果,但该结果未进入数字2的列。
答案 0 :(得分:0)
用于百分比计算的默认数据类型为likley,导致数据丢失。
您需要将值强制转换为小数/浮点数/双精度数等。
select 1/10
-- 0
select 1/10 * 100
-- 0
select cast(1 as decimal)/cast(10 as decimal)
-- 0.1000000000000000000
select cast(1 as decimal)/cast(10 as decimal) * 100
-- 10.0000000000000000
select cast(cast(1 as decimal)/cast(10 as decimal) * 100 as int)
-- 10
select cast(cast(cast(1 as decimal)/cast(10 as decimal) * 100 as int) as varchar(4)) + '%'
-- 10%