-1
這是對Sakila示例數據庫的查詢。我不確定爲什麼COUNT爲每一行返回'1' - 我希望它計算該國家/城市/郵政編碼組合中的客戶數量。爲什麼COUNT計數這個MySQL語句中的東西?
SELECT country.country_id, country.country, city.city_id, city.city, address.postal_code, COUNT(*) AS 'Customer Count'
FROM address
INNER JOIN city ON city.city_id = address.city_id
INNER JOIN country ON country.country_id = city.country_id
INNER JOIN customer ON customer.address_id = address.address_id
GROUP BY country.country, city.city, address.postal_code
關於我在做什麼的錯誤?
下面是一些輸出:
每個國家/城市/郵政編碼組合是否有多行?你確定計數是否應該大於1? –
結果看起來不錯,因爲沒有超過1個客戶的國家/城市組合。 – user2989408
您的意見是什麼:可以在某個國家的任何城市重複郵政編碼嗎? –