Excel → T-SQL › MAXIFS

MAXIFS to SQL MAX with WHERE

Latest order per customer is a classic. MAX(order_date) GROUP BY customer_id.

SELECT customer_id, MAX(order_date) AS last_shipped
FROM Orders
WHERE status = 'Shipped'
GROUP BY customer_id;

Need the whole row, not just the date? That is ROW_NUMBER, not MAXIFS.

Canonical translation

SELECT customer_id, MAX(order_date) AS last_shipped
FROM Orders
WHERE status = 'Shipped'
GROUP BY customer_id;

Then write it on a ticket

Monday is free. A colleague asks, you type, we mark it.

Clock in free