Nvidia vs AMD: Who Won the Last 12 Months?
$10,000 in Nvidia vs $10,000 in AMD a year ago — what each is worth today, the winner, and each stock's best and worst day. Live prices, pulled fresh every run.
4 steps · shared by Klajdi · September 25, 2026
No data is shared in this template. It contains only the recipe — column names and SQL logic. When you run it, your data is processed in your own browser and never leaves your machine.
How it works — every step, readable
- 01Daily prices — Nvidia and AMD (last 12 months)filters to the relevant rows · sorts the output
SELECT ticker, CAST(date AS DATE) AS date, CAST(adj_close AS DOUBLE) AS adj_close FROM read_csv_auto('STOOQ_NVDA_AMD.csv', header=true) WHERE adj_close IS NOT NULL ORDER BY ticker, date - 02Assumptions — edit these
SELECT * FROM (VALUES ('Amount invested', 10000, 'USD')) AS t(assumption, value, unit) - 03What $10,000 grew intocombines data from multiple inputs · aggregates rows into summary totals · buckets values by condition
WITH a AS (SELECT MAX(CASE WHEN assumption = 'Amount invested' THEN CAST(value AS DOUBLE) END) AS amt FROM input_2), b AS (SELECT ticker, arg_min(adj_close, date) AS p0 FROM input_1 GROUP BY ticker) SELECT date, ROUND(MAX(CASE WHEN i.ticker = 'NVDA' THEN a.amt * i.adj_close / b.p0 END), 2) AS nvidia_value, ROUND(MAX(CASE WHEN i.ticker = 'AMD' THEN a.amt * i.adj_close / b.p0 END), 2) AS amd_value FROM input_1 i JOIN b USING (ticker) CROSS JOIN a GROUP BY date HAVING COUNT(*) = 2 ORDER BY date - 04The punch linesaggregates rows into summary totals · buckets values by condition · computes running / windowed totals
WITH g AS (SELECT * FROM input_1), f AS (SELECT * FROM g ORDER BY date LIMIT 1), l AS (SELECT * FROM g ORDER BY date DESC LIMIT 1), r AS (SELECT ticker, date, adj_close / LAG(adj_close) OVER (PARTITION BY ticker ORDER BY date) - 1 AS d FROM input_2), x AS (SELECT ticker, arg_max(date, d) AS bd, max(d) AS bmax, arg_min(date, d) AS wd, min(d) AS wmin FROM r WHERE d IS NOT NULL GROUP BY ticker), s AS (SELECT f.nvidia_value AS amt, l.nvidia_value AS nv, l.amd_value AS av, f.date AS d0, l.date AS d1 FROM f, l) SELECT area, finding, next_step FROM ( SELECT 1 AS o, 'VERDICT' AS area, '▲ ' || CASE WHEN nv >= av THEN 'NVIDIA' ELSE 'AMD' END || ' WINS — Nvidia ' || printf('%+.0f%%', 100.0 * (nv / amt - 1)) || ' vs AMD ' || printf('%+.0f%%', 100.0 * (av / amt - 1)) || ' since ' || strftime(d0, '%b %-d, %Y') AS finding, '' AS next_step FROM s UNION ALL SELECT 2, ('$' || format('{:,}', CAST(ROUND(amt) AS BIGINT))) || ' in Nvidia', ('$' || format('{:,}', CAST(ROUND(nv) AS BIGINT))) || ' today', 'Bought ' || strftime(d0, '%b %-d, %Y') || ', valued ' || strftime(d1, '%b %-d') FROM s UNION ALL SELECT 3, ('$' || format('{:,}', CAST(ROUND(amt) AS BIGINT))) || ' in AMD', ('$' || format('{:,}', CAST(ROUND(av) AS BIGINT))) || ' today', 'Same day, same amount' FROM s UNION ALL SELECT 4, 'The gap', ('$' || format('{:,}', CAST(ROUND(abs(nv - av)) AS BIGINT))) || ' more in ' || CASE WHEN nv >= av THEN 'Nvidia' ELSE 'AMD' END, 'Picking the right chip stock was worth ' || ('$' || format('{:,}', CAST(ROUND(abs(nv - av)) AS BIGINT))) FROM s UNION ALL SELECT 5, 'Nvidia''s best day', printf('%+.1f%%', 100.0 * (bmax)) || ' on ' || strftime(bd, '%b %-d'), 'Worst: ' || printf('%+.1f%%', 100.0 * (wmin)) || ' on ' || strftime(wd, '%b %-d') FROM x WHERE ticker = 'NVDA' UNION ALL SELECT 6, 'AMD''s best day', printf('%+.1f%%', 100.0 * (bmax)) || ' on ' || strftime(bd, '%b %-d'), 'Worst: ' || printf('%+.1f%%', 100.0 * (wmin)) || ' on ' || strftime(wd, '%b %-d') FROM x WHERE ticker = 'AMD' ) ORDER BY o
Run this on your books
Free to try — no sign-up, no card. The workflow runs in your browser; your data never leaves your machine.
Make it your own →