Hi everyone! I'm blaming this problem on Monday fog, but I can't seem to return the record that has a max value in it. It's easy to return:
SELECT Account, Max(Points)
FROM Table
GROUP BY Account
but when I want to include other fields from that particular record with the resultset I'm being forced to use another aggregation which I don't want to do. I want the other fields from this specific maximum point record! If I try:
SELECT Account, Max(Points), Type
FROM Table
GROUP BY Account
I get the expected error message that Type must be included in the aggregation or group by lines - I don't want any aggregation on Type, I want the Type that goes with the record that has the maximum points for that account.
When I put it in the GROUP BY as below:
SELECT Account, Max(Points), Type
FROM Table
GROUP BY Account, Type
to eliminate the error message, it gives incorrect records in many cases, with the Max(Points) not given, just Max(Points) where the Type value is greatest.
I'd sure appreciate any help. Thanks!
SELECT Account, Max(Points)
FROM Table
GROUP BY Account
but when I want to include other fields from that particular record with the resultset I'm being forced to use another aggregation which I don't want to do. I want the other fields from this specific maximum point record! If I try:
SELECT Account, Max(Points), Type
FROM Table
GROUP BY Account
I get the expected error message that Type must be included in the aggregation or group by lines - I don't want any aggregation on Type, I want the Type that goes with the record that has the maximum points for that account.
When I put it in the GROUP BY as below:
SELECT Account, Max(Points), Type
FROM Table
GROUP BY Account, Type
to eliminate the error message, it gives incorrect records in many cases, with the Max(Points) not given, just Max(Points) where the Type value is greatest.
I'd sure appreciate any help. Thanks!