Plenty of people write SQL like that. It’s usually Python devs who are overly fascinated with shitty AI.
with toporders as (
select max(order_total) as maxOT, customer_id
from orders
group by customer_id
)
select last_name, maxOT
from customers join toporders
on ...
What would you suggest? SELECT
customer.first_name,
customer.last_name,
max(order.order_total) as maximum_order
FROM
customers customer
INNER JOIN
orders order
ON (customer.id = order.customer_id)
GROUP BY
customer.id