> ## Documentation Index
> Fetch the complete documentation index at: https://docs.stockful.app/llms.txt
> Use this file to discover all available pages before exploring further.

# Sales

> Fulfilled order lines: units, revenue and margin over a date range.

Fulfilled order lines: units, revenue and margin over a date range.

## Example

```sql theme={null}
FROM sales
  SHOW units_sold, line_count
  GROUP BY product
  ORDER BY units_sold DESC
```

## Metrics

| Metric                | Type     | Description                                                                     |
| --------------------- | -------- | ------------------------------------------------------------------------------- |
| `units_sold`          | Number   | Units sold in the selected period.                                              |
| `line_count`          | Number   | Number of fulfilled order lines in the period.                                  |
| `total_revenue`       | Currency | Gross revenue from sales in the period.                                         |
| `unit_cost`           | Currency | Cost per unit; 0 when no cost is set.                                           |
| `total_cogs`          | Currency | Cost of goods sold (units sold × unit cost) in the period.                      |
| `gross_profit`        | Currency | Revenue minus cost of goods sold in the period.                                 |
| `landed_cogs`         | Currency | Cost of goods sold at true landed cost, including allocated freight and duties. |
| `landed_gross_profit` | Currency | Revenue minus landed cost of goods sold - margin after freight and duties.      |
| `period_days`         | Number   | How many days the report's date range covers.                                   |
| `landed_margin_pct`   | Percent  | Landed gross profit as a percentage of revenue.                                 |
| `profit_margin`       | Percent  | Gross profit as a percentage of revenue.                                        |

## Dimensions

| Dimension       | Description                                                                                                                                                                                 |
| --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `product`       | Product with image, rendered as a single cell (variants roll up).                                                                                                                           |
| `sku`           | Variant SKU - splits a product-grain report into variant rows.                                                                                                                              |
| `variant`       | Variant title (e.g. "Small / Blue"), shown as a dash for products without options. Group by product too - on its own, variants sharing a title across different products fall into one row. |
| `barcode`       | Variant barcode (GTIN/UPC/EAN/ISBN), grouping under a blank value when none.                                                                                                                |
| `category`      | Shopify product category (full taxonomy path).                                                                                                                                              |
| `collection`    | Shopify collection - a SKU appears under each collection it belongs to (cross-collection totals overlap), grouping under a blank value when it is in none.                                  |
| `location`      | Sales location.                                                                                                                                                                             |
| `vendor`        | Product vendor.                                                                                                                                                                             |
| `product_type`  | Shopify product type.                                                                                                                                                                       |
| `tag`           | Individual product tag - a SKU appears under each of its tags (cross-tag totals overlap).                                                                                                   |
| `location_role` | Whether the fulfilling location acts as a hub or a fulfillment location.                                                                                                                    |
| `order_channel` | The channel the order came through, such as the online store, POS, or a marketplace. Orders with no recorded channel group under Unknown.                                                   |
| `order_source`  | Where the order was placed: web, POS, or a channel app. Coarser than order channel; use it to split online from in-person.                                                                  |
| `promotion`     | The declared promotion covering the sale date, from the promotion calendar. Days outside every declared window group under None.                                                            |

## Filters

| Filter                     | Type   | Description                                                                                                                                         |
| -------------------------- | ------ | --------------------------------------------------------------------------------------------------------------------------------------------------- |
| `collection`               | Number | Restrict to products in the selected collection(s).                                                                                                 |
| `category`                 | Text   | Restrict to products in the selected category (matches sub-categories too).                                                                         |
| `sales_channel`            | Number | Restrict to products published to the selected sales channel.                                                                                       |
| `region_catalog`           | Number | Restrict to products in the selected region (market) catalog.                                                                                       |
| `b2b_catalog`              | Number | Restrict to products in the selected B2B (market) catalog.                                                                                          |
| `company_location_catalog` | Number | Restrict to products in the selected company-location catalog.                                                                                      |
| `vendor`                   | Text   | Product vendor.                                                                                                                                     |
| `product_type`             | Text   | Shopify product type.                                                                                                                               |
| `sku`                      | Text   | Variant SKU.                                                                                                                                        |
| `barcode`                  | Text   | Variant barcode.                                                                                                                                    |
| `location_name`            | Text   | Sales location name.                                                                                                                                |
| `order_channel`            | Text   | The channel the order came through. Distinct from `sales_channel`, which filters on where a product is listed rather than where an order came from. |
| `order_source`             | Text   | Where the order was placed: web, POS, or a channel app.                                                                                             |
| `promotion`                | Text   | Name of the declared promotion covering the sale date. Null outside every declared window.                                                          |

<Note>
  Order channel is recorded from the point it was added, so orders older than that, and orders whose channel has not yet been filled in by the nightly sync, group under **Unknown** rather than being counted as direct sales.
</Note>

## Related datasets

* [Sales trends](/stockfulql/datasets/sales_history)
* [Returns](/stockfulql/datasets/returns)
* [Promotions](/stockfulql/datasets/promo)
