This commit is contained in:
Correl Roush 2022-12-21 16:29:10 -05:00
parent e4653a3bea
commit 1c45b59db7

View file

@ -210,6 +210,49 @@ https://www.topdecked.com/decks/alive/833c308f-219f-4624-8b32-1adedcb477f0
: Deck = Deck [PreferredCard]
* Collection stats
#+begin_src sql
SELECT COUNT("copies"."id") AS cards
, SUM(
CASE WHEN "copies"."isFoil"
THEN "card_prices"."usd_foil"
ELSE "card_prices"."usd"
END
) AS value
, COUNT(DISTINCT cards.set_code) AS sets
FROM "copies"
JOIN "cards" USING ("scryfall_id")
LEFT JOIN "card_prices" USING ("scryfall_id")
WHERE "card_prices"."date" = (SELECT "value" FROM "vars" where "key" = 'last_update')
#+end_src
#+RESULTS:
| cards | value | sets |
|-------+---------+------|
| 12871 | 7289.44 | 161 |
#+begin_src sql
SELECT COUNT("copies"."id") AS cards
FROM "copies"
JOIN "cards" USING ("scryfall_id")
LEFT JOIN "card_prices" USING ("scryfall_id")
WHERE "card_prices"."date" = (SELECT "value" FROM "vars" where "key" = 'last_update')
#+end_src
#+RESULTS:
| cards |
|-------|
| 12871 |
#+begin_src sql
select count(*) from copies
#+end_src
#+RESULTS:
| count |
|-------|
| 12871 |
* Identifying and ordering sets
#+name: sets
#+begin_src sql