SampleSQL: Sales Orders where all items are marked as lost demand


WARNING icon
Data Query is an Advanced User feature.

This sample Data Query may be useful, for example, for listing sales orders that have been fully lost demanded. It will list each item on the order along with the order code, the customer's name and financial information for the items on the order.

SELECT aso.sorder_code, aso.date_created, 
 cu.company_code, cu.company_name,
 sk.stock_code, sk.short_desc,
 ld.qty_user, ld.net_unit as 'Net Unit',
 ld.gross_unit as 'Gross Unit',
 ld.tax1_amount as 'Tax', ld.net_amount as 'Net total',
 ld.tax1_amount + ld.net_amount as 'Gross Total'
 FROM lost_demand AS ld
INNER JOIN audit_sorder AS aso ON ld.sorder_id = aso.sorder_id
INNER JOIN stock AS sk ON ld.stock_id = sk.stock_id
INNER JOIN company AS cu ON aso.company_id = cu.company_id
LEFT JOIN sorder AS so ON aso.sorder_id = so.sorder_id
WHERE so.sorder_id IS NULL
ORDER BY aso.sorder_code
/************************************************************
 Sales Orders where all items are marked as lost demand

 This data query is provided as a teaching aid and is not
 covered by your support agreement

 13-Mar-2012 Created (Matt)
************************************************************/

To lost demand a whole order please select Lost Demand - Whole Order from the Sales Orders Grid Context Menu


Did you find this article helpful?