0
你好,我有一個表w /以下信息。postgres sql查詢使用group by子句和子查詢
agent (agent_id, salary, city, country)
我試圖做出fullfils這個請求的查詢...
「在每個國家至少有6個城市名單代理商代理的數量和工資總額。」
我的問題是如何組織不安全的國家和統計與該國相關城市的數量。我不太確定如何執行所需的子查詢或group by子句。我正在嘗試像下面這樣的東西...
select COUNT(agent_id) as numOfAgents, SUM(salary) as Salary, DISTINCT country
from agent
where city = (select COUNT(city) from agent where city > '5')
我知道這個查詢不起作用,我需要以某種方式介紹group by子句。
謝謝你的解釋。 – user3622460