嗨,我想在以下查询中显示县,但如果县不存在,则返回城市。
SELECT P.id AS id, SUM(P.price) AS price,
P.tax,
county
FROM Purchases AS P
JOIN Status AS S ON S.id = T.status_id
JOIN Shipping AS Ship ON S.shipping_id= Ship.id
JOIN Shipping_Addresses AS SA ON Ship.shipping_address_id = SA.id
JOIN Zip_Codes AS ZIP ON ZIP.zip_code = SA.zip_code
JOIN Counties AS C ON ZIP.city = C.city
JOIN States AS STATE ON STATE.id = C.county_state_id
GROUP BY ZIP.zip_code
ORDER BY county
谢谢