ERROR: syntax error at or near "settlement_date"
ERROR: syntax error at or near "settlement_date"
错误:"settlement_date" 处或附近的语法错误
第 4 行:如果 settlement_date > '2015-01-01'
^
********** 错误 **********
错误:"settlement_date"
处或附近的语法错误
SQL 状态:42601
字符数:50
update "Recon".ship_error
set
if settlement_date > '2015-01-01'
then
shipping_fee = case
when shipping_zone = 'NA' and order_status !='return_completed' then 0
when shipping_zone = 'NATIONAL' and total_weight <= 0.5 and order_status !='return_completed' then -55
when shipping_zone = 'LOCAL' and total_weight <= 0.5 and order_status !='return_completed' then -29.4
when shipping_zone = 'ZONAL' and total_weight <= 0.5 and order_status !='return_completed' then -55
when shipping_zone = 'NA' and order_status !='return_completed' then 0
when shipping_zone = 'NATIONAL' and total_weight >= 0.5 and total_weight <= 1 and order_status !='return_completed' then -55
when shipping_zone = 'LOCAL' and total_weight >= 0.5 and total_weight <=1 order_status !='return_completed' then -29.4
when shipping_zone = 'ZONAL' and total_weight >= 0.5 and total_weight <=1 order_status !='return_completed' then -55
end
end
if settlement_date <= '2015-01-01'
then
when shipping_zone = 'NA' and order_status !='return_completed' then 0
when shipping_zone = 'NATIONAL' and total_weight <= 0.5 and order_status !='return_completed' then -43.4
when shipping_zone = 'LOCAL' and total_weight <= 0.5 and order_status !='return_completed' then -24.3
when shipping_zone = 'ZONAL' and total_weight <= 0.5 and order_status !='return_completed' then -43.4
when shipping_zone = 'NA' and order_status !='return_completed' then 0
when shipping_zone = 'NATIONAL' and total_weight >= 0.5 and total_weight <= 1 and order_status !='return_completed' then -86.8
when shipping_zone = 'LOCAL' and total_weight >= 0.5 and total_weight <=1 order_status !='return_completed' then -58.3
when shipping_zone = 'ZONAL' and total_weight >= 0.5 and total_weight <=1 order_status !='return_completed' then -86.8
end
end
from "Recon".ship_error;
或者我也试过这个代码
update "Recon".ship_error
set shipping_fee = case
when settlement_date > '2015-01-01'
then
--shipping_fee = case
when shipping_zone = 'NA' and order_status !='return_completed' then 0
when shipping_zone = 'NATIONAL' and total_weight <= 0.5 and order_status !='return_completed' then -55
when shipping_zone = 'LOCAL' and total_weight <= 0.5 and order_status !='return_completed' then -29.4
when shipping_zone = 'ZONAL' and total_weight <= 0.5 and order_status !='return_completed' then -55
when shipping_zone = 'NA' and order_status !='return_completed' then 0
when shipping_zone = 'NATIONAL' and total_weight >= 0.5 and total_weight <= 1 and order_status !='return_completed' then -55
when shipping_zone = 'LOCAL' and total_weight >= 0.5 and total_weight <=1 order_status !='return_completed' then -29.4
when shipping_zone = 'ZONAL' and total_weight >= 0.5 and total_weight <=1 order_status !='return_completed' then -55
end
end
when settlement_date <= '2015-01-01'
then
when shipping_zone = 'NA' and order_status !='return_completed' then 0
when shipping_zone = 'NATIONAL' and total_weight <= 0.5 and order_status !='return_completed' then -43.4
when shipping_zone = 'LOCAL' and total_weight <= 0.5 and order_status !='return_completed' then -24.3
when shipping_zone = 'ZONAL' and total_weight <= 0.5 and order_status !='return_completed' then -43.4
when shipping_zone = 'NA' and order_status !='return_completed' then 0
when shipping_zone = 'NATIONAL' and total_weight >= 0.5 and total_weight <= 1 and order_status !='return_completed' then -86.8
when shipping_zone = 'LOCAL' and total_weight >= 0.5 and total_weight <=1 order_status !='return_completed' then -58.3
when shipping_zone = 'ZONAL' and total_weight >= 0.5 and total_weight <=1 order_status !='return_completed' then -86.8
end
end
from "Recon".ship_error;
您的查询有几个错误(有几次缺少 and
和额外的 end
等)。这是更正的查询:
UPDATE "Recon".ship_error
SET shipping_fee = CASE
WHEN settlement_date > '2015-01-01'
THEN
CASE
WHEN shipping_zone = 'NA'
AND order_status != 'return_completed'
THEN 0
WHEN shipping_zone = 'NATIONAL'
AND total_weight <= 0.5
AND order_status != 'return_completed'
THEN - 55
WHEN shipping_zone = 'LOCAL'
AND total_weight <= 0.5
AND order_status != 'return_completed'
THEN - 29.4
WHEN shipping_zone = 'ZONAL'
AND total_weight <= 0.5
AND order_status != 'return_completed'
THEN - 55
WHEN shipping_zone = 'NA'
AND order_status != 'return_completed'
THEN 0
WHEN shipping_zone = 'NATIONAL'
AND total_weight >= 0.5
AND total_weight <= 1
AND order_status != 'return_completed'
THEN - 55
WHEN shipping_zone = 'LOCAL'
AND total_weight >= 0.5
AND total_weight <= 1
AND order_status != 'return_completed'
THEN - 29.4
WHEN shipping_zone = 'ZONAL'
AND total_weight >= 0.5
AND total_weight <= 1
AND order_status != 'return_completed'
THEN - 55
END
WHEN settlement_date <= '2015-01-01'
THEN CASE
WHEN shipping_zone = 'NA'
AND order_status != 'return_completed'
THEN 0
WHEN shipping_zone = 'NATIONAL'
AND total_weight <= 0.5
AND order_status != 'return_completed'
THEN - 43.4
WHEN shipping_zone = 'LOCAL'
AND total_weight <= 0.5
AND order_status != 'return_completed'
THEN - 24.3
WHEN shipping_zone = 'ZONAL'
AND total_weight <= 0.5
AND order_status != 'return_completed'
THEN - 43.4
WHEN shipping_zone = 'NA'
AND order_status != 'return_completed'
THEN 0
WHEN shipping_zone = 'NATIONAL'
AND total_weight >= 0.5
AND total_weight <= 1
AND order_status != 'return_completed'
THEN - 86.8
WHEN shipping_zone = 'LOCAL'
AND total_weight >= 0.5
AND total_weight <= 1
AND order_status != 'return_completed'
THEN - 58.3
WHEN shipping_zone = 'ZONAL'
AND total_weight >= 0.5
AND total_weight <= 1
AND order_status != 'return_completed'
THEN - 86.8
END
END;
update "Recon".ship_error
set shipping_fee = case
--shipping_fee = case
when shipping_zone = 'NA' and order_status !='return_completed' then 0
when shipping_zone = 'NATIONAL' and total_weight <= 0.5 and settlement_date > '2015-01-01' and order_status !='return_completed' then -55
when shipping_zone = 'LOCAL' and total_weight <= 0.5 and settlement_date > '2015-01-01' and order_status !='return_completed' then -29.4
when shipping_zone = 'ZONAL' and total_weight <= 0.5 and settlement_date > '2015-01-01' and order_status !='return_completed' then -55
when shipping_zone = 'NA' and order_status !='return_completed' then 0
when shipping_zone = 'NATIONAL' and total_weight >= 0.5 and total_weight <= 1 and settlement_date > '2015-01-01' and order_status !='return_completed' then -55
when shipping_zone = 'LOCAL' and total_weight >= 0.5 and total_weight <=1 and settlement_date > '2015-01-01' and order_status !='return_completed' then -29.4
when shipping_zone = 'ZONAL' and total_weight >= 0.5 and total_weight <=1 and settlement_date > '2015-01-01' and order_status !='return_completed' then -55
when shipping_zone = 'NA' and order_status !='return_completed' then 0
when shipping_zone = 'NATIONAL' and total_weight <= 0.5 and settlement_date <= '2015-01-01' and order_status !='return_completed' then -43.4
when shipping_zone = 'LOCAL' and total_weight <= 0.5 and settlement_date <= '2015-01-01' and order_status !='return_completed' then -29.4
when shipping_zone = 'ZONAL' and total_weight <= 0.5 and settlement_date <= '2015-01-01' and order_status !='return_completed' then -43.4
when shipping_zone = 'NA' and order_status !='return_completed' then 0
when shipping_zone = 'NATIONAL' and total_weight >= 0.5 and total_weight <= 1 and settlement_date <= '2015-01-01' and order_status !='return_completed' then -86.8
when shipping_zone = 'LOCAL' and total_weight >= 0.5 and total_weight <=1 and settlement_date <= '2015-01-01' and order_status !='return_completed' then -58.8
when shipping_zone = 'ZONAL' and total_weight >= 0.5 and total_weight <=1 and settlement_date <= '2015-01-01' and order_status !='return_completed' then -86.8
end ;
错误:"settlement_date" 处或附近的语法错误 第 4 行:如果 settlement_date > '2015-01-01' ^ ********** 错误 **********
错误:"settlement_date"
处或附近的语法错误SQL 状态:42601
字符数:50
update "Recon".ship_error
set
if settlement_date > '2015-01-01'
then
shipping_fee = case
when shipping_zone = 'NA' and order_status !='return_completed' then 0
when shipping_zone = 'NATIONAL' and total_weight <= 0.5 and order_status !='return_completed' then -55
when shipping_zone = 'LOCAL' and total_weight <= 0.5 and order_status !='return_completed' then -29.4
when shipping_zone = 'ZONAL' and total_weight <= 0.5 and order_status !='return_completed' then -55
when shipping_zone = 'NA' and order_status !='return_completed' then 0
when shipping_zone = 'NATIONAL' and total_weight >= 0.5 and total_weight <= 1 and order_status !='return_completed' then -55
when shipping_zone = 'LOCAL' and total_weight >= 0.5 and total_weight <=1 order_status !='return_completed' then -29.4
when shipping_zone = 'ZONAL' and total_weight >= 0.5 and total_weight <=1 order_status !='return_completed' then -55
end
end
if settlement_date <= '2015-01-01'
then
when shipping_zone = 'NA' and order_status !='return_completed' then 0
when shipping_zone = 'NATIONAL' and total_weight <= 0.5 and order_status !='return_completed' then -43.4
when shipping_zone = 'LOCAL' and total_weight <= 0.5 and order_status !='return_completed' then -24.3
when shipping_zone = 'ZONAL' and total_weight <= 0.5 and order_status !='return_completed' then -43.4
when shipping_zone = 'NA' and order_status !='return_completed' then 0
when shipping_zone = 'NATIONAL' and total_weight >= 0.5 and total_weight <= 1 and order_status !='return_completed' then -86.8
when shipping_zone = 'LOCAL' and total_weight >= 0.5 and total_weight <=1 order_status !='return_completed' then -58.3
when shipping_zone = 'ZONAL' and total_weight >= 0.5 and total_weight <=1 order_status !='return_completed' then -86.8
end
end
from "Recon".ship_error;
或者我也试过这个代码
update "Recon".ship_error
set shipping_fee = case
when settlement_date > '2015-01-01'
then
--shipping_fee = case
when shipping_zone = 'NA' and order_status !='return_completed' then 0
when shipping_zone = 'NATIONAL' and total_weight <= 0.5 and order_status !='return_completed' then -55
when shipping_zone = 'LOCAL' and total_weight <= 0.5 and order_status !='return_completed' then -29.4
when shipping_zone = 'ZONAL' and total_weight <= 0.5 and order_status !='return_completed' then -55
when shipping_zone = 'NA' and order_status !='return_completed' then 0
when shipping_zone = 'NATIONAL' and total_weight >= 0.5 and total_weight <= 1 and order_status !='return_completed' then -55
when shipping_zone = 'LOCAL' and total_weight >= 0.5 and total_weight <=1 order_status !='return_completed' then -29.4
when shipping_zone = 'ZONAL' and total_weight >= 0.5 and total_weight <=1 order_status !='return_completed' then -55
end
end
when settlement_date <= '2015-01-01'
then
when shipping_zone = 'NA' and order_status !='return_completed' then 0
when shipping_zone = 'NATIONAL' and total_weight <= 0.5 and order_status !='return_completed' then -43.4
when shipping_zone = 'LOCAL' and total_weight <= 0.5 and order_status !='return_completed' then -24.3
when shipping_zone = 'ZONAL' and total_weight <= 0.5 and order_status !='return_completed' then -43.4
when shipping_zone = 'NA' and order_status !='return_completed' then 0
when shipping_zone = 'NATIONAL' and total_weight >= 0.5 and total_weight <= 1 and order_status !='return_completed' then -86.8
when shipping_zone = 'LOCAL' and total_weight >= 0.5 and total_weight <=1 order_status !='return_completed' then -58.3
when shipping_zone = 'ZONAL' and total_weight >= 0.5 and total_weight <=1 order_status !='return_completed' then -86.8
end
end
from "Recon".ship_error;
您的查询有几个错误(有几次缺少 and
和额外的 end
等)。这是更正的查询:
UPDATE "Recon".ship_error
SET shipping_fee = CASE
WHEN settlement_date > '2015-01-01'
THEN
CASE
WHEN shipping_zone = 'NA'
AND order_status != 'return_completed'
THEN 0
WHEN shipping_zone = 'NATIONAL'
AND total_weight <= 0.5
AND order_status != 'return_completed'
THEN - 55
WHEN shipping_zone = 'LOCAL'
AND total_weight <= 0.5
AND order_status != 'return_completed'
THEN - 29.4
WHEN shipping_zone = 'ZONAL'
AND total_weight <= 0.5
AND order_status != 'return_completed'
THEN - 55
WHEN shipping_zone = 'NA'
AND order_status != 'return_completed'
THEN 0
WHEN shipping_zone = 'NATIONAL'
AND total_weight >= 0.5
AND total_weight <= 1
AND order_status != 'return_completed'
THEN - 55
WHEN shipping_zone = 'LOCAL'
AND total_weight >= 0.5
AND total_weight <= 1
AND order_status != 'return_completed'
THEN - 29.4
WHEN shipping_zone = 'ZONAL'
AND total_weight >= 0.5
AND total_weight <= 1
AND order_status != 'return_completed'
THEN - 55
END
WHEN settlement_date <= '2015-01-01'
THEN CASE
WHEN shipping_zone = 'NA'
AND order_status != 'return_completed'
THEN 0
WHEN shipping_zone = 'NATIONAL'
AND total_weight <= 0.5
AND order_status != 'return_completed'
THEN - 43.4
WHEN shipping_zone = 'LOCAL'
AND total_weight <= 0.5
AND order_status != 'return_completed'
THEN - 24.3
WHEN shipping_zone = 'ZONAL'
AND total_weight <= 0.5
AND order_status != 'return_completed'
THEN - 43.4
WHEN shipping_zone = 'NA'
AND order_status != 'return_completed'
THEN 0
WHEN shipping_zone = 'NATIONAL'
AND total_weight >= 0.5
AND total_weight <= 1
AND order_status != 'return_completed'
THEN - 86.8
WHEN shipping_zone = 'LOCAL'
AND total_weight >= 0.5
AND total_weight <= 1
AND order_status != 'return_completed'
THEN - 58.3
WHEN shipping_zone = 'ZONAL'
AND total_weight >= 0.5
AND total_weight <= 1
AND order_status != 'return_completed'
THEN - 86.8
END
END;
update "Recon".ship_error
set shipping_fee = case
--shipping_fee = case
when shipping_zone = 'NA' and order_status !='return_completed' then 0
when shipping_zone = 'NATIONAL' and total_weight <= 0.5 and settlement_date > '2015-01-01' and order_status !='return_completed' then -55
when shipping_zone = 'LOCAL' and total_weight <= 0.5 and settlement_date > '2015-01-01' and order_status !='return_completed' then -29.4
when shipping_zone = 'ZONAL' and total_weight <= 0.5 and settlement_date > '2015-01-01' and order_status !='return_completed' then -55
when shipping_zone = 'NA' and order_status !='return_completed' then 0
when shipping_zone = 'NATIONAL' and total_weight >= 0.5 and total_weight <= 1 and settlement_date > '2015-01-01' and order_status !='return_completed' then -55
when shipping_zone = 'LOCAL' and total_weight >= 0.5 and total_weight <=1 and settlement_date > '2015-01-01' and order_status !='return_completed' then -29.4
when shipping_zone = 'ZONAL' and total_weight >= 0.5 and total_weight <=1 and settlement_date > '2015-01-01' and order_status !='return_completed' then -55
when shipping_zone = 'NA' and order_status !='return_completed' then 0
when shipping_zone = 'NATIONAL' and total_weight <= 0.5 and settlement_date <= '2015-01-01' and order_status !='return_completed' then -43.4
when shipping_zone = 'LOCAL' and total_weight <= 0.5 and settlement_date <= '2015-01-01' and order_status !='return_completed' then -29.4
when shipping_zone = 'ZONAL' and total_weight <= 0.5 and settlement_date <= '2015-01-01' and order_status !='return_completed' then -43.4
when shipping_zone = 'NA' and order_status !='return_completed' then 0
when shipping_zone = 'NATIONAL' and total_weight >= 0.5 and total_weight <= 1 and settlement_date <= '2015-01-01' and order_status !='return_completed' then -86.8
when shipping_zone = 'LOCAL' and total_weight >= 0.5 and total_weight <=1 and settlement_date <= '2015-01-01' and order_status !='return_completed' then -58.8
when shipping_zone = 'ZONAL' and total_weight >= 0.5 and total_weight <=1 and settlement_date <= '2015-01-01' and order_status !='return_completed' then -86.8
end ;