I need to do something like this in sql. For example :
CASE city
WHEN ["",""] THEN '[]', //if there is no city i must return '[]'
WHEN ["Paris",""] THEN '["Paris"]' // i just have to return [ "Paris"] instead of ["Paris",""]
WHEN ["Paris","Paris"] THEN '["Paris"]' // without duplicated values
ELSE 'other'
END
How can I do this please ?
Thank's for your help
这是你需要的吗?
CASE
WHEN city = '' THEN '[]' -- if there is no city i must return '[]'
WHEN city = '["Paris",""]' THEN '["Paris"]' -- i just have to return [ "Paris"] instead of ["Paris",""]
WHEN city = '["Paris","Paris"]' THEN '["Paris"]' --// without duplicated values
ELSE 'other'
END
向我们展示一些示例表数据和预期结果。(作为格式化文本,没有图像。)
什么是城市类型?
城市类型是 Varchar(100)
您正在尝试将一个值 -- city-- 与一个ARRAY值进行比较。它永远不会匹配。
你能举一个城市价值和预期产出的例子吗?