sql server 2008 - How to query the max quantity of grouped records and display that date -
i have view sums quantity of items based on item , date. want query results max(quantity) along date. if max(quantity) has multiple dates, want display oldest. want 1 record. here data example: example 1 item quantity date i1 100 1/1/2010 i1 100 2/1/2010 i1 5 3/1/2010 in case want see first record oldest date. because using max, need group by. how can rewrite query. can use store procedure if needed. display in report. select item, max(quantity), loaddate vwarchivequantitybyloaddate item = 'i1' group item, loaddate order item, loaddate using sql server 2008, reporting services. just 1 way without using max. sql fiddle demo select top 1 item, quantity, date vwarchivequantitybyloaddate item = 'i1' order quantity desc, date desc