Re: Last order date for each customer



On Mon, 8 May 2006 09:32:01 -0700, chas2006 wrote:

I would like to write a select statement in query analyzer which would return
the last order number per customer given a specific order type. (Which would
be 1 record per customer) Thanks.

Hi chas2006,

Questions like this are imppossible to answer without knowing how your
database looks. Please post table structure (as CREATE TABLE statements,
including constraints and properties), some rows of sample data (as
INSERT statements) and expected results.

Maybe something like this?

SELECT Customer, MAX(OrderNumber)
FROM Orders
WHERE OrderType = 17
GROUP BY Customer

--
Hugo Kornelis, SQL Server MVP
.