OK, My brain if fragged today, and I know this must be simple, but I'm not getting it.
Here's the table:
select * from padr;
prodcode | liccount | date
----------+----------+---------------------
A | 1 | 2003-05-06 07:00:00
A | 5 | 2003-05-06 07:00:00
A | 4 | 2003-05-06 12:30:00
A | 5 | 2003-05-06 13:30:00
A | 2 | 2003-05-06 03:30:00
A | 1 | 2003-05-06 13:30:00
B | 4 | 2003-05-06 14:01:00
B | 1 | 2003-05-06 12:30:00
B | 2 | 2003-05-06 10:30:00
B | 3 | 2003-05-06 09:30:00
B | 3 | 2003-05-06 06:30:00
Now, what I want is the date field that matches the largest liccount for each prodcode. I can get the largest liccount for each prodcode with
select prodcode,max(liccount) from padr p1 group by prodcode;
but how do I get the associated date field to go with it?