I have this data in my table:
onum amt odate cnum snum
3001 18,69 1990-03-10 00:00:00.000 2008 1007
3002 1900,10 1990-03-10 00:00:00.000 2007 1004
3003 767,19 1990-03-10 00:00:00.000 2001 1001
3005 5160,45 1990-03-10 00:00:00.000 2003 1002
3006 1098,16 1990-03-10 00:00:00.000 2008 1007
3007 75,75 1990-03-10 00:00:00.000 2004 1002
3008 4723,00 1990-05-10 00:00:00.000 2006 1001
3009 1713,23 1990-04-10 00:00:00.000 2002 1003
3010 1309,95 1990-06-10 00:00:00.000 2004 1002
3011 9891,88 1990-06-10 00:00:00.000 2006 1001
I need get this result:
amt odate snum
5160,45 1990-03-10 00:00:00.000 1002
4723,00 1990-05-10 00:00:00.000 1001
9891,88 1990-06-10 00:00:00.000 1001
that is I select the max amt
on the each day odate
, but with displaying of seller snum
if I write this:
SELECT MAX(amt), odate, snum
FROM [Understanding].[dbo].[Orders]
GROUP BY odate, snum
the output is wrong because it displays the groups by days and sellers.