title: How to use Max method for 2 Column
body: <p>i have a problem with using max method in sql
  when i want run this query it give me this error</p>
  
  <pre><code>select max(id),oid,ofactid,obtype,obcount,
         ofi,osaved,osum,ototalsum,oworkdate,max(lastdate) 
  from [blokDB].[dbo].[tblOrdersBuy] 
  where oid=1
  </code></pre>
  
  <p>return this error</p>
  
  <p>Column 'blokDB.dbo.tblOrdersBuy.ofactid' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.</p>