I hope you can deduce what i am asking from the excel spreadsheet
it has 3 tables listed and the desired results. I don't know how to write this query.
the problem area is the gallons table.
please refer to spreadsheet.
it has to do with selecting row data from a max value where the max value is not known. and then a 2nd max also experts-exchange.xlsx
Microsoft SQL ServerSQL
Last Comment
Jim Metcalf
8/22/2022 - Mon
Peter Chan
1. Put group by columns in your query please.
2. Put
2. Put
max(isnull(column1,0))...
in case the column is null.