> ## 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. |
| `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.                                                                                                                    |
| `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.                                                                               |
| `location_name`            | Text   | Sales location name.                                                                       |
| `promotion`                | Text   | Name of the declared promotion covering the sale date. Null outside every declared window. |

## Related datasets

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