sales_order Table
The sales_order table (sales_flat_order on M1) is where each order is captured. Usually, each row represents one unique order, although there are some custom implementations of Commerce that result in splitting an order into separate rows.
This table includes all customer orders, whether that order was processed through guest checkout. If your store accepts guest checkout, you can find more information about this use case.
Common Columns
Column Name
Description
base_currency_codeCurrency for all values captured in
base_* fields (that is base_grand_total, base_subtotal, and so on). This typically reflects the Commerce store’s default currencybase_discount_amountDiscount value applied to order
base_grand_totalFinal price paid by the customer on the order, after all taxes, shipping, and discounts are applied. Although the precise calculation is customizable, in general the
base_grand_total is calculated as base_subtotal + base_tax_amount + base_shipping_amount + base_discount_amount - base_gift_cards_amount - base_customer_balance_amountbase_subtotalGross merchandise value of all items included in the order. Taxes, shipping, discounts, and so on, are not included
base_shipping_amountShipping value applied to order
base_tax_amountTax value applied to order
billing_address_idForeign key associated with the sales_order_address table. Join to sales_order_address.entity_id to determine the billing address details associated with the ordercoupon_codeCoupon applied to order. If no coupon is applied, this field is
NULLcreated_atCreation timestamp of the order, stored locally in UTC. Depending on your configuration in Commerce Intelligence, this timestamp may be converted to a reporting time zone in Commerce Intelligence that differs from your database time zone
customer_emailEmail address of the customer placing the order. This is populated in all situations, including orders processed through guest checkout
customer_group_idForeign key associated with the
customer_group table. Join to customer_group.customer_group_id to determine the customer group associated with the ordercustomer_idForeign key associated with the customer_entity table, if the customer is registered. Join to customer_entity.entity_id to determine customer attributes associated with the order. If the order was placed through guest checkout, this field is NULLentity_id (PK)Unique identifier for the table, and commonly used in joins to other tables within the Commerce instance
increment_idUnique identifier for an order, and commonly referred to as the
order_id within Adobe Commerce. The increment_id is most often used for joins to external sources, such as Google Ecommerceshipping_address_idForeign key associated with the
sales_order_address table. Join to sales_order_address.entity_id to determine the shipping address details associated with the orderstatusOrder’s status. May return values such as ‘complete’, ‘processing’, ‘cancelled’, ‘refunded’, and any custom statuses implemented on the Commerce instance. Subject to changes as the order gets processed
store_idForeign key associated with the store table. Join to store.store_id to determine which Commerce store view is associated with the orderCommon Calculated Columns
Column Name
Description
Billing address cityBilling city for the order. Calculated by joining
sales_order.billing_address_id to sales_order_address.entity_id and returning the city fieldBilling address countryBilling country code for the order. Calculated by joining
sales_order.billing_address_id to sales_order_address.entity_id and returning the country_idBilling address regionBilling region (most often state or province) for the order. Calculated by joining
sales_order.billing_address_id to sales_order_address.entity_id and returning the region fieldCustomer's first order dateTimestamp of the first order placed by this customer. Often considered to be the “acquisition date” for a customer. Calculated by returning the minimum
sales_order.created_at value for each unique customerCustomer's first order's billing regionAcquisition billing region for the customer who placed the order. Calculated by returning the
Billing address region associated with the customer’s first orderCustomer's first order's coupon_codeAcquisition coupon code for the customer who placed this order. Calculated by returning the
coupon_code associated with the customer’s first orderCustomer's group codeGroup name of the customer who placed this order. Calculated by joining
sales_order.customer_group_id to customer_group.customer_group_id and returning the customer_group_code fieldCustomer's lifetime number of couponsTotal quantity of coupons applied to all orders placed by this customer. Calculated by counting the number of orders where the
coupon_code is not NULL for each unique customerCustomer's lifetime number of ordersTotal count of orders placed by this customer. Calculated by counting the number of rows in the
sales_order table for each unique customerCustomer's lifetime revenueSum total of revenue for all orders placed by this customer. Calculated by summing the
base_grand_total field for all orders for each unique customerCustomer's order numberSequential order rank for this customer’s order. Calculated by identifying all orders placed by a customer, sorting them in ascending order by the
created_at timestamp, and assigning an incrementing integer value to each order. For example, the customer’s first order returns a Customer's order number of 1, the customer’s second order returns a Customer's order number of 2, and so on.Customer's order number (previous-current)Rank of customer’s previous order concatenated with the rank of this order, separated by a
- character. Calculated by concatenating (“Customer's order number - 1”) with “-” followed by “Customer's order number”. For example, for the order associated with the customer’s second purchase, this column returns a value of 1-2. Most often used when representing the time between two order events (that is, in the “Time between orders” chart)Is customer's last order?Determines whether the order corresponds to the customer’s last, or most recent, order. Calculated by comparing the
Customer's order number value with Customer's lifetime number of orders. When these two fields are equal for the given order, this column returns Yes; otherwise it returns NoNumber of items in orderTotal quantity of items included in the order. Calculated by joining
sales_order.entity_id to sales_order_item.order_id and summing the sales_order_item.qty_ordered fieldSeconds between customer's first order date and this orderElapsed time between this order and the customer’s first order. Calculated by subtracting
Customer's first order date from the created_at for each order, returned as an integer number of secondsSeconds since previous orderElapsed time between this order and the customer’s immediately preceding order. Calculated by subtracting the
created_at for the previous order from the created_at of this order, returned as an integer number of seconds. For example, for the order record corresponding to a customer’s third order, this column returns the number of seconds between the customer’s second order and third order. For the customer’s first order, this field returns NULLShipping address cityShipping city for the order. Calculated by joining
sales_order.shipping_address_id to sales_order_address.entity_id and returning the city fieldShipping address countryShipping country code for the order. Calculated by joining
sales_order.Shipping_address_id to sales_order_address.entity_id and returning the country_idShipping address regionShipping region (most often state or province) for the order. Calculated by joining
sales_order.shipping_address_id to sales_order_address.entity_id and returning the region fieldStore nameThe name of the Commerce store associated with this order. Calculated by joining
sales_order.store_id to store.store_id and returning the name fieldCommon Metrics
Metric Name
Description
Construction
Avg order valueThe average revenue per order, where revenue is defined as the
base_grand_totalOperation: AverageOperand: base_grand_totalTimestamp: created_atAvg time between ordersThe average time between a customer’s (n-1) order and nth order, for all customers and orders
Operation: AverageOperand: Seconds since previous orderTimestamp: created_atGMVThe sum of the gross merchandise value for all orders, where GMV is defined as the subtotal, before all taxes and discounts are applied
Operation: SumOperand: base_subtotalTimestamp: created_atMedian time between ordersThe median time between a customer’s (n-1) order and nth order, for all customers and orders
Operation: MedianOperand: Seconds since previous orderTimestamp: created_atOrdersThe total count of orders placed
Operation: CountOperand: entity_idTimestamp: created_atRevenueThe sum of the revenue for all orders, where revenue is defined as the final price paid by the customer, after all taxes, discounts, shipping, and so on, are applied
Operation: SumOperand: base_grand_totalTimestamp: created_atShippingThe sum of the shipping amount for all orders
Operation: SumOperand: base_shipping_amountTimestamp: created_atTaxThe sum of the taxes applied to all orders
Operation: SumOperand: base_tax_amountTimestamp: created_atUnique CustomersThe number of unique customers placing an order in the given reporting time interval. For example if the report’s interval was weekly, each customer who places at least one order in a given week is counted exactly once, regardless of how many orders they placed in that week
Operation: Count DistinctOperand: customer_emailTimestamp: created_atForeign Key Joining Paths
customer_entity
- Join to
customer_entitytable to create new customer-level columns associated with the customer who placed the order.- Path:
sales_order.customer_id(many) =>customer_entity.entity_id(one)
- Path:
customer_group
- Join to
customer_grouptable to create columns that return the customer group name of the customer who placed the order.- Path:
sales_order.customer_group_id(many) =>customer_group.customer_group_id(one)
- Path:
sales_order_address
-
Join to
sales_order_addresstable to create columns that return billing and shipping locations associated with the order. Two joining paths are possible, depending on whether the billing or shipping details are required.-
Paths:
- Shipping:
sales_order.shipping_address_id(many) =>sales_order_address.entity_id(one) - Billing:
sales_order.billing_address_id(many) =>sales_order_address.entity_id(one)
- Shipping:
-
store
- Join to
storetable to create columns that return details related to the Commerce store associated with the order.- Path:
sales_order.store_id(many) =>store.store_id(one)
- Path:
recommendation-more-help
e1f8a7e8-8cc7-4c99-9697-b1daa1d66dbc