SELECT Postcode, Cost =
CASE
WHEN Postcode LIKE '4%' THEN 8.00
WHEN Postcode LIKE '2%' THEN 4.65
ELSE 'unknown'
END
或
SELECT Postcode, Cost =
CASE
WHEN Postcode BETWEEN '1000' AND '1999' THEN 8.00
WHEN Postcode BETWEEN '2000' AND '2999' THEN 4.65
...
ELSE 'unknown'
END
1条答案
按热度按时间mklgxw1f1#
审判案件https://www.w3schools.com/sql/func_mysql_case.asp
像这样:
或