Comment 8 for bug 1257915

Revision history for this message
Blake GH (bmagic) wrote :

This query might have identified the situation:

select purchase_order,string_agg(cancel_reason::text,',') from acq.lineitem where purchase_order in(
select id from acq.purchase_order where state='on-order' and id not in
(
select purchase_order from acq.lineitem where state in('cancelled') and cancel_reason in(select id from acq.cancel_reason where keep_debits) and purchase_order is not null
)
and id in
(select purchase_order from acq.lineitem where state in('cancelled'))
and id not in
(select purchase_order from acq.lineitem where state not in('received','cancelled') and purchase_order is not null)
)
group by purchase_order
order by purchase_order