title: Best way to get MAX customer in my SQL code
body: <p>Per product, I need to know which customer had the greatest quantity of inventory shipped over a period of time.  I only want 1 customer per product to return in my results.  I know I should be using the MAX on the QtyShip but I can't wrap my head around where.  In a subquery?</p>
  
  <p>I've started with the code below.  Can someone show me where I throw in the max here?</p>
  
  <pre><code>Select o.cono ,
  o.ProdId ,
  o.CustId ,
  c.[name] as 'CustomerName' ,
  s.shipto ,
  s.[name] as 'ShiptoName' ,
  s.user15 as 'divno' ,
  o.WhseId ,
  SUM(NetAmt) as 'totalNet' ,
  SUM(cost) as 'totalCost' ,
  SUM(QtyShip) as 'totalQtyShip'
  FROM Order_Line_Invoice o
  LEFT JOIN ARSC c
      on  o.cono = c.cono
          and o.CustId = c.custno
          and c.insx = 1
  LEFT JOIN ARSS s
      on  o.cono = s.cono
          and o.CustId = s.custno
          and o.ShipToId = s.shipto
          and s.insx = 1
  GROUP BY o.cono ,
  o.ProdId ,
  o.CustId ,
  c.[name] ,
  s.shipto ,
  s.[name] ,
  s.user15 ,
  o.WhseId
  </code></pre>