AI Reports

Guides › Database reference › Orders and sales

Magento 2 sales_order_item table

One row per product line in an order. Configurable and bundle products have a parent row plus child rows, so the same sale can appear twice.

Key columns

ColumnWhat it means
item_idInternal ID of the order line.
order_idThe order, linking to sales_order.entity_id.
parent_item_idNULL for a top-level line. For the chosen variant of a configurable product (or a bundle part), the parent line's item_id.
product_idThe product's ID at the time of ordering. On the parent line of a configurable product, it's the configurable product.
sku / nameCopied at order time. On the parent line of a configurable product, sku is the chosen variant's SKU.
product_typesimple, configurable, bundle, virtual and so on.
qty_orderedQuantity ordered. Also qty_invoiced, qty_shipped, qty_refunded and qty_canceled.
price / row_totalUnit price and price × quantity, before discount and without tax. base_ versions are in your base currency.
discount_amountThe line's discount, stored as a positive number (unlike sales_order).

Good to know

Example: Top 10 products by quantity sold, last 30 days

Works on Magento Open Source and Adobe Commerce.

SELECT i.sku, MAX(i.name) AS name, SUM(i.qty_ordered) AS qty, ROUND(SUM(i.base_row_total), 2) AS revenue
FROM sales_order_item i
JOIN sales_order o ON o.entity_id = i.order_id
WHERE o.created_at >= NOW() - INTERVAL 30 DAY
  AND o.state NOT IN ('canceled', 'closed')
  AND i.parent_item_id IS NULL      -- one row per product line
GROUP BY i.sku
ORDER BY qty DESC
LIMIT 10;

Tested on Magento Open Source and Adobe Commerce 2.4.8. Read-only. If your tables have a prefix, add it to each table name.

Extra columns on Adobe Commerce

Adobe Commerce has 96 columns here instead of 80. The extra ones come from these Commerce features:

Foreign keys

All 80 columns (Magento Open Source)

Show all columns
ColumnTypeCan be emptyMagento's description
item_idint(10) unsignedItem ID
order_idint(10) unsignedOrder ID
parent_item_idint(10) unsignedyesParent Item ID
quote_item_idint(10) unsignedyesQuote Item ID
store_idsmallint(5) unsignedyesStore ID
created_attimestampCreated At
updated_attimestampUpdated At
product_idint(10) unsignedyesProduct ID
product_typevarchar(255)yesProduct Type
product_optionslongtextyesProduct Options
weightdecimal(12,4)yesWeight
is_virtualsmallint(5) unsignedyesIs Virtual
skuvarchar(255)yesSku
namevarchar(255)yesName
descriptiontextyesDescription
applied_rule_idstextyesApplied Rule Ids
additional_datatextyesAdditional Data
is_qty_decimalsmallint(5) unsignedyesIs Qty Decimal
no_discountsmallint(5) unsignedNo Discount
qty_backordereddecimal(12,4)yesQty Backordered
qty_canceleddecimal(12,4)yesQty Canceled
qty_invoiceddecimal(12,4)yesQty Invoiced
qty_ordereddecimal(12,4)yesQty Ordered
qty_refundeddecimal(12,4)yesQty Refunded
qty_shippeddecimal(12,4)yesQty Shipped
base_costdecimal(12,4)yesBase Cost
pricedecimal(20,4)Price
base_pricedecimal(20,4)Base Price
original_pricedecimal(20,4)yesOriginal Price
base_original_pricedecimal(20,4)yesBase Original Price
tax_percentdecimal(12,4)yesTax Percent
tax_amountdecimal(20,4)yesTax Amount
base_tax_amountdecimal(20,4)yesBase Tax Amount
tax_invoiceddecimal(20,4)yesTax Invoiced
base_tax_invoiceddecimal(20,4)yesBase Tax Invoiced
discount_percentdecimal(12,4)yesDiscount Percent
discount_amountdecimal(20,4)yesDiscount Amount
base_discount_amountdecimal(20,4)yesBase Discount Amount
discount_invoiceddecimal(20,4)yesDiscount Invoiced
base_discount_invoiceddecimal(20,4)yesBase Discount Invoiced
amount_refundeddecimal(20,4)yesAmount Refunded
base_amount_refundeddecimal(20,4)yesBase Amount Refunded
row_totaldecimal(20,4)Row Total
base_row_totaldecimal(20,4)Base Row Total
row_invoiceddecimal(20,4)Row Invoiced
base_row_invoiceddecimal(20,4)Base Row Invoiced
row_weightdecimal(12,4)yesRow Weight
base_tax_before_discountdecimal(20,4)yesBase Tax Before Discount
tax_before_discountdecimal(20,4)yesTax Before Discount
ext_order_item_idvarchar(255)yesExt Order Item ID
locked_do_invoicesmallint(5) unsignedyesLocked Do Invoice
locked_do_shipsmallint(5) unsignedyesLocked Do Ship
price_incl_taxdecimal(20,4)yesPrice Incl Tax
base_price_incl_taxdecimal(20,4)yesBase Price Incl Tax
row_total_incl_taxdecimal(20,4)yesRow Total Incl Tax
base_row_total_incl_taxdecimal(20,4)yesBase Row Total Incl Tax
discount_tax_compensation_amountdecimal(20,4)yesDiscount Tax Compensation Amount
base_discount_tax_compensation_amountdecimal(20,4)yesBase Discount Tax Compensation Amount
discount_tax_compensation_invoiceddecimal(20,4)yesDiscount Tax Compensation Invoiced
base_discount_tax_compensation_invoiceddecimal(20,4)yesBase Discount Tax Compensation Invoiced
discount_tax_compensation_refundeddecimal(20,4)yesDiscount Tax Compensation Refunded
base_discount_tax_compensation_refundeddecimal(20,4)yesBase Discount Tax Compensation Refunded
tax_canceleddecimal(12,4)yesTax Canceled
discount_tax_compensation_canceleddecimal(20,4)yesDiscount Tax Compensation Canceled
tax_refundeddecimal(20,4)yesTax Refunded
base_tax_refundeddecimal(20,4)yesBase Tax Refunded
discount_refundeddecimal(20,4)yesDiscount Refunded
base_discount_refundeddecimal(20,4)yesBase Discount Refunded
weee_tax_appliedtextyesWeee Tax Applied
weee_tax_applied_amountdecimal(12,4)yesWeee Tax Applied Amount
weee_tax_applied_row_amountdecimal(12,4)yesWeee Tax Applied Row Amount
weee_tax_dispositiondecimal(12,4)yesWeee Tax Disposition
weee_tax_row_dispositiondecimal(12,4)yesWeee Tax Row Disposition
base_weee_tax_applied_amountdecimal(12,4)yesBase Weee Tax Applied Amount
base_weee_tax_applied_row_amntdecimal(12,4)yesBase Weee Tax Applied Row Amnt
base_weee_tax_dispositiondecimal(12,4)yesBase Weee Tax Disposition
base_weee_tax_row_dispositiondecimal(12,4)yesBase Weee Tax Row Disposition
gift_message_idint(11)yesGift Message ID
gift_message_availableint(11)yesGift Message Available
free_shippingsmallint(5) unsignedFree Shipping

Related tables

Gaurav Harsh

Gaurav Harsh is a Magento developer who works on large Adobe Commerce stores and builds AI Reports, a Magento extension for asking your store's data questions in plain English. LinkedIn