Created
October 1, 2019 21:27
-
-
Save ryantuck/72d48d82076d7dd14a9bd0459061722f to your computer and use it in GitHub Desktop.
Idea for writing a SQL query in yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from: | |
base: orders | |
joins: | |
- name: items | |
type: inner | |
on: items.order_id = orders.id | |
- name: products | |
type: inner | |
on: products.id = items.product_id | |
- name: shipments | |
type: left | |
on: shipments.order_id = orders.id | |
where: | |
- orders.placed >= '2019-09-01' | |
select: | |
dimensions: | |
product_name: products.name | |
measures: | |
total_orders: | |
type: count_distinct | |
sql: orders.id | |
average_price: | |
type: average | |
sql: items.amount | |
not_yet_shipped: | |
type: count | |
sql: case when shipments.id is true then 1 else 0 end | |
order_by: | |
- name: total_orders | |
type: desc | |
limit: 50 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment