Skip to content

Instantly share code, notes, and snippets.

View thomasthaddeus's full-sized avatar
:dependabot:
Building things to make life easier

Thaddeus Thomas thomasthaddeus

:dependabot:
Building things to make life easier
View GitHub Profile
@thomasthaddeus
thomasthaddeus / purchases.sqlite
Created August 4, 2022 04:47
Queries to remember
SELECT purchase_id, DATE(purchase_date, '7 days')
FROM purchases;
SELECT STRFTIME('%H', purchase_date)
FROM purchases;
SELECT date, (CAST(high AS 'REAL') +
CAST(low as 'REAL')) / 2.0 AS 'average'
FROM weather
;
@thomasthaddeus
thomasthaddeus / streams.sqlite
Created July 25, 2022 18:36
Window Functions in SQL
SELECT
artist,
week,
streams_millions,
streams_millions - LAG(streams_millions, 1, streams_millions) OVER (
PARTITION BY artist
ORDER BY week
) AS 'streams_millions_change',
chart_position,
LAG(chart_position, 1, chart_position) OVER (