Skip to content

Instantly share code, notes, and snippets.

-- Get the number of orders for every customer signed in the last year:
WITH customers_with_orders AS MATERIALIZED ( -- [needs "MATERIALIZED" only for PG12+]
SELECT customer_id, signup_date, count(*) n_orders
FROM remote.customers c
JOIN remote.orders o ON c.id = o.customer_id
GROUP BY 1, 2
)
SELECT *
FROM customers_with_orders
WHERE signup_date > current_date - 365
@antoine-lizee
antoine-lizee / hackathon_test.py
Last active November 16, 2021 15:36
Fetch issues & comments from Topics
import json
import time
import requests
issues_url = 'https://api.github.com/repos/alan-eu/Topics/issues'
comments_url = 'https://api.github.com/repos/alan-eu/Topics/issues/comments'
rate_limit_url = 'https://api.github.com/rate_limit'
headers = {'Authorization': 'token <your_token>', 'Accept': 'application/vnd.github.v3+json'}