2025-01-27 18:39:35 +01:00
|
|
|
{% extends 'minifigure/base/base.sql' %}
|
2025-01-17 11:03:00 +01:00
|
|
|
|
|
|
|
{% block total_missing %}
|
2025-01-20 19:39:12 +01:00
|
|
|
SUM(IFNULL("missing_join"."total", 0)) AS "total_missing",
|
2025-01-17 11:03:00 +01:00
|
|
|
{% endblock %}
|
|
|
|
|
2025-01-24 10:25:40 +01:00
|
|
|
{% block total_quantity %}
|
2025-01-27 18:39:35 +01:00
|
|
|
SUM(IFNULL("bricktracker_minifigures"."quantity", 0)) AS "total_quantity",
|
2025-01-17 11:03:00 +01:00
|
|
|
{% endblock %}
|
|
|
|
|
|
|
|
{% block total_sets %}
|
2025-01-27 18:39:35 +01:00
|
|
|
COUNT("bricktracker_minifigures"."bricktracker_set_id") AS "total_sets"
|
2025-01-17 11:03:00 +01:00
|
|
|
{% endblock %}
|
|
|
|
|
|
|
|
{% block join %}
|
|
|
|
-- LEFT JOIN + SELECT to avoid messing the total
|
|
|
|
LEFT JOIN (
|
|
|
|
SELECT
|
2025-01-20 19:39:12 +01:00
|
|
|
"missing"."set_num",
|
|
|
|
"missing"."u_id",
|
|
|
|
SUM("missing"."quantity") AS total
|
|
|
|
FROM "missing"
|
2025-01-17 11:03:00 +01:00
|
|
|
GROUP BY
|
2025-01-20 19:39:12 +01:00
|
|
|
"missing"."set_num",
|
|
|
|
"missing"."u_id"
|
2025-01-17 11:03:00 +01:00
|
|
|
) missing_join
|
2025-01-27 18:39:35 +01:00
|
|
|
ON "bricktracker_minifigures"."bricktracker_set_id" IS NOT DISTINCT FROM "missing_join"."u_id"
|
|
|
|
AND "rebrickable_minifigures"."figure" IS NOT DISTINCT FROM "missing_join"."set_num"
|
2025-01-17 11:03:00 +01:00
|
|
|
{% endblock %}
|
|
|
|
|
|
|
|
{% block group %}
|
|
|
|
GROUP BY
|
2025-01-27 18:39:35 +01:00
|
|
|
"rebrickable_minifigures"."figure"
|
2025-01-17 11:03:00 +01:00
|
|
|
{% endblock %}
|