I am trying to retrieve the account ID with the highest amount of RESTAURANT orders, and I am getting this account 74e785c8482534f1de441afd7d245c2c38a237bf8612ef9a6bd292baadba71e5 with 462 of orders, but the correct question from what I see is 59a4daa0619c067d79f9c0be27dfe61d91bad7058dea5cd5e964482409484f50 with 431 of orders, I am trying to understand what I am doing wrong and still can not get it, even used chat GTP to explain, and he agrees with me, I took the data from following link if you want to check https://www.dropbox.com/s/uuwrpkpdktajpnk/bda_data.zip .
SELECT account_id, count(order_origin = "RESTAURANT") as Order_From_Restaurant
FROM ord_sample
GROUP BY account_id
ORDER BY Order_From_Restaurant DESC
LIMIT 10
Also if you want to check, here is the code that i used
I am expecting to understand which is the correct answer, I tried different ways to approach the problem, but I always receive this result, that is different from the results that was told as correct.
Your statement, simplified, does do something different then you expect.
see: DBFIDDLE
count(order_origin = "RESTAURANT")will count all values where the result fororder_origin = "RESTAURANT"is not equal to NULL.