Comments
Comments are notes that you add to a ShopifyQL query. ShopifyQL ignores them when it runs the query, so they don't change the results. Use them to document what a query does or to stop part of it from running while you test.
Syntax
Comments can explain sections of a query or prevent execution of query text.
- Anchor to line commentline commentline comment-- comment-- comment
Starts with
--and ends at the end of the line.- Anchor to block commentblock commentblock comment/* comment *//* comment */
Starts with
/*, ends with*/, and can span multiple lines.
Anchor to Line commentsLine comments
Use a line comment to leave a short note next to a clause, or to disable a single line while you test a query.
ShopifyQL
Examples
Description
Report [`gross_profit`](/docs/api/shopifyql/latest/schemas/sales_revenue/sales#salesmetric-propertydetail-grossprofit) by day for the current month. This example uses a line comment (`--`) to record why the query keeps only sales with a recorded cost.
ShopifyQL
FROM sales SHOW net_sales_with_cost_recorded, cost_of_goods_sold, gross_profit WHERE cost_is_recorded = true -- Drop sales with no recorded cost so margin isn't overstated TIMESERIES day SINCE startOfMonth(0m) UNTIL today VISUALIZE gross_profit TYPE tableDescription
Show [`total_sales`](/docs/api/shopifyql/latest/schemas/sales_revenue/sales#salesmetric-propertydetail-totalsales) and `orders` by day for the current month. This example comments out the [`WHERE`](/docs/api/shopifyql/latest/syntax/where) line with `--` so the query runs across all customers. Delete the `--` to re-apply the new-customer filter.
ShopifyQL
FROM sales SHOW total_sales, orders -- WHERE new_or_returning_customer = 'New' TIMESERIES day SINCE startOfMonth(0m) UNTIL today VISUALIZE total_sales TYPE line
Anchor to Block commentsBlock comments
Use a block comment for a longer note, such as what a saved query is for or who maintains it, or to disable several lines at once. A block comment can sit anywhere in a query, not just at the top.
ShopifyQL
Examples
Description
Track new [`customers`](/docs/api/shopifyql/latest/schemas/sales_revenue/sales#salesmetric-propertydetail-customers), orders, and sales day by day over the last 30 days, against the previous 30-day period. This example uses a block comment at the top to record what the query powers and who owns it.
ShopifyQL
/* Powers the weekly growth review. Owned by the analytics team. Check before changing the date range. */ FROM sales SHOW customers, orders, total_sales WHERE new_or_returning_customer = 'New' TIMESERIES day WITH TOTALS, PERCENT_CHANGE SINCE startOfDay(-30d) UNTIL today COMPARE TO previous_period ORDER BY day ASC LIMIT 1000 VISUALIZE customers TYPE lineDescription
Report [`gross_sales`](/docs/api/shopifyql/latest/schemas/sales_revenue/sales#salesmetric-propertydetail-grosssales), discounts, and net sales by month for the year to date. This example uses a block comment between clauses to disable a filter and explain why.
ShopifyQL
FROM sales SHOW gross_sales, discounts, net_sales /* Showing every customer for the summary view. Re-enable this filter for the new-customer report. WHERE new_or_returning_customer = 'New' */ TIMESERIES month SINCE startOfYear(0y) UNTIL today VISUALIZE net_sales TYPE line