<?php require_once('header.php');
$strSQL = "SELECT a.com_id,a.com_no,a.com_name,a.com_serial,a.com_buydate,b.owner_name,b.owner_code FROM tblcom a LEFT JOIN tblowner b ON a.com_id = b.com_id group BY a.com_no ASC";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
select * from (
select [artnumber, max(datetime) `วันที่หลังสุด`
from table group by partnumber ) as o
left join table as t on t.partnumber = o.partnumber and t.datetime = o.`วันที่หลังสุด`