Last active
August 18, 2022 12:23
-
-
Save garystafford/d7dcc04d29d07807c57000e087975c6c to your computer and use it in GitHub Desktop.
This file contains 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
{{ config(materialized='view', bind=False) }} | |
with source as ( | |
select * from {{ source('tickit_external', 'sale') }} | |
), | |
renamed as ( | |
select | |
saleid as sale_id, | |
listid as list_id, | |
sellerid as seller_id, | |
buyerid as buyer_id, | |
eventid as event_id, | |
dateid as date_id, | |
qtysold as qty_sold, | |
round (pricepaid / qtysold, 2) as ticket_price, | |
pricepaid as price_paid, | |
round((commission / pricepaid) * 100, 2) as commission_prcnt, | |
commission, | |
(pricepaid - commission) as earnings, | |
saletime as sale_time | |
from | |
source | |
where | |
sale_id IS NOT NULL | |
order by | |
sale_id | |
) | |
select * from renamed |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment