When writing queries that group and aggregate, it is not uncommon for there to be many columns in the SELECT clause that are neither in the GROUP BY clause nor being aggregated. For example, in a customer orders database, suppose you want a query that returns customer names, telephone numbers, and total order amount. A correct, but somewhat naive solution would go like this:
select c.Name, c.Phone, sum( o.Amount ) as Amount_sum
from Customers c
join Orders o on o.CustomerID = c.CustomerID
group by c.Name, c.Phone
This will return the desired results, but in my experience, will not deliver ...