G
Guest
I use SQL once a year so struggle on the simplest tings.
I want to retrieve the entire row/record for a series of the max values.
Its easiest enough to get the values to display is they are in the GROUP BY
clause but its returning incorrect results. I think I need a statement
similar to:
Select MAX(SaleDate), Item, Salesman From Log Group By Item
....but it won't display the Salesman column because its not in one of the
aggregate functions. I want the Salesman value from the record that has the
most recent sales for each item.
The data might look like
SaleDate Item Salesman
1/1/01 Candy Bob
1/5/01 Candy Sally
1/5/01 Toy Sally
1/6/01 Toy Bob
I need the query to return (one row per item):
SaleDate Item Salesman
1/5/01 Candy Sally
1/6/01 Toay Bob
I want to retrieve the entire row/record for a series of the max values.
Its easiest enough to get the values to display is they are in the GROUP BY
clause but its returning incorrect results. I think I need a statement
similar to:
Select MAX(SaleDate), Item, Salesman From Log Group By Item
....but it won't display the Salesman column because its not in one of the
aggregate functions. I want the Salesman value from the record that has the
most recent sales for each item.
The data might look like
SaleDate Item Salesman
1/1/01 Candy Bob
1/5/01 Candy Sally
1/5/01 Toy Sally
1/6/01 Toy Bob
I need the query to return (one row per item):
SaleDate Item Salesman
1/5/01 Candy Sally
1/6/01 Toay Bob