Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
259 B
2
Indexable
Never
SELECT DISTINCT user_id, 
CAST(DATE_TRUNC('month',paid_at) as date) as month,
MIN(CAST(DATE_TRUNC('month',paid_at) as DATE)) OVER (partition by user_id) as first_paid_at 
FROM tools_shop.orders
WHERE CAST(DATE_TRUNC('YEAR',paid_at) as date) = '2020-01-01'