SELECT
`o2`.`hn`,
`o2`.`an`,
`o1`.`qty`,
`o1`.`vn`,
`o1`.`icode`,
`drugitems`.`did`,
`ovst_seq`.`seq_id`,
`o2`.`oqueue`,
`v`.`cid`
FROM
`opitemrece` AS `o1`
Left Outer Join `ovst` AS `o2` ON `o2`.`vn` = `o1`.`vn`
Left Outer Join `vn_stat` AS `v` ON `v`.`vn` = `o2`.`vn`
Left Outer Join `drugitems` ON `drugitems`.`icode` = `o1`.`icode`
Left Outer Join `pcu_drugitems` AS `d` ON `d`.`did` = `drugitems`.`did`
Left Outer Join `ovst_seq` ON `ovst_seq`.`vn` = `o2`.`vn`
Left Outer Join `person` ON `person`.`cid` = `v`.`cid`
WHERE
`o1`.`vstdate` BETWEEN '2007-10-01' AND '2007-10-31' AND
`o1`.`icode` LIKE '1%' AND
`o1`.`vn` is not null
ได้ 17656 records