I have a payment table where a customer may have made multiple payments on account. I want to pull the customer id, the amount and the MAX date. Problem is when I ask for MAX date, I have to put the other fields in a GROUP BY to get a return. That gives me all the payments instead of just the one line I want.[code="sql"]CREATE TABLE test_max (id varchar(4), date_created date, amount decimal(8,2))INSERT INTO test_max VALUES (1, '2-12-16', '14.00') , (1,'2-15-16', '35.00') , (1,'2-28-16', '11.00') , (1,'2-13-16', '40.00') SELECT id , MAX(date_created) , amountFROM test_maxGROUP BY id , amount[/code]What I want to see is just the third line 1, 2-28-16, 11.00 because that is the MAX date with the id and the amount paid on that date.
↧