@PeterFatd1 WITH agent_cnt AS (
SELECT AgentID,
COUNT(*) AS Delivery_cnt
FROM deliveries
GROUP BY AgentID
)
SELECT
AgentID,
Delivery_Cnt
FROM agent_cnt
WHERE Delivery_Cnt > (
SELECT AVG(Delivery_Cnt)
FROM agent_cnt )
ORDER BY Delivery_Cnt DESC;
I came across this SQL query and something immediately caught my attention.
It looks correct at first glanceβ¦ but thereβs actually a problem hiding somewhere.
Can you spot it? ππ½
Look at the query carefully and tell me which line is causing the problem and why.
Iβll be checking the comments.
#SQL
@PeterFatd1 WITH product_totals AS (
SELECT
Factory, Product,
SUM(UnitsProduced) AS Total_Units,
RANK() OVER (PARTITION BY Factory
ORDER BY SUM(UnitsProduced) DESC
) AS rnk
FROM Production
GROUP BY Factory, Product
)
@drealbigvirg The comments show how frustrated people are in this country...
The end of that tweet already shows that it was a joke. π€£π€£π€£π€£π€£
@lastborn211@Wizarab10@VictorSica88010 Harry winks lives in London while playing for Leicester city (over 2 hours commute).
Luca Digne commutes from London while playing for Villa (Abt 2 hours drive).