Search 800 + Posts

Apr 1, 2023

Query to Join DOO_ORDER_HEADERS, DOO_ORDER_LINES and DOO_ORDER_FULFILLMENT_LINES

SELECT oo.order_number, oo.order_date, oo.customer_name, ol.product_number, ol.quantity_ordered, ol.unit_price, oof.quantity_shipped, oof.shipment_date FROM DOO_ORDER_HEADERS oo INNER JOIN DOO_ORDER_LINES ol ON ol.header_id = oo.header_id INNER JOIN DOO_ORDER_FULFILLMENT_LINES oof ON oof.line_id = ol.line_id;

This query will return all rows from the DOO_ORDER_HEADERS, DOO_ORDER_LINES, and DOO_ORDER_FULFILLMENT_LINES tables, where the header_id column in the DOO_ORDER_LINES table is equal to the line_id column in the DOO_ORDER_FULFILLMENT_LINES table.

The DOO_ORDER_HEADERS table contains information about orders, such as the order number, order date, and customer name. The DOO_ORDER_LINES table contains information about the individual line items on an order, such as the product number, quantity ordered, and unit price. The DOO_ORDER_FULFILLMENT_LINES table contains information about the individual line items on an order that have been fulfilled, such as the quantity shipped and the shipment date.

This query can be used to retrieve information about all the line items on an order, or to retrieve information about all the orders that have been placed by a particular customer.

No comments:

Post a Comment