BrickTracker/bricktracker/sql/minifigure/list/all.sql

35 lines
937 B
MySQL
Raw Normal View History

2025-01-27 18:39:35 +01:00
{% extends 'minifigure/base/base.sql' %}
2025-01-17 11:03:00 +01:00
{% block total_missing %}
SUM(IFNULL("missing_join"."total", 0)) AS "total_missing",
2025-01-17 11:03:00 +01:00
{% endblock %}
{% 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
"missing"."set_num",
"missing"."u_id",
SUM("missing"."quantity") AS total
FROM "missing"
2025-01-17 11:03:00 +01:00
GROUP BY
"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 %}