select h.material_type as 物料类型,h.lot_number as 物料条码, h.lot_ids as 批次号,h.consumption_qty as 事务数量, h.consumption_date as 操作时间, m.customer_lot_number as 客户批次号,
(select instance_id from named_object z where z.instance_rrn = h.item_rrn ) as 物料号,
( select z.mask_id from item z where z.item_rrn = h.item_rrn ) as 物料规格,
(select instance_id from named_object z where z.instance_rrn = (select t.product_rrn from lot t where t.lot_id = h.lot_ids ) ) as 产品名,
(select le.outer_order_no from lot_ext le where le.lot_rrn = h.lot_rrns ) as 工单号,
(select instance_id from named_object zz where lsh.operation_rrn = zz.instance_rrn) as 工步号
from lot_consumes_material_history h, wasmc_material_lot m,
lot_trans_history lth, lot_step_history lsh
where h.lot_number = m.lot_number and h.trans_rrn =lth.trans_rrn
and h.lot_rrns = lsh.lot_rrn and
lth.step_sequence = lsh.step_sequence
order by h.trans_rrn desc, h.trans_sequence desc