.bail ON .mode table --wrap 0 SELECT datetime(value, 'unixepoch') 'DB version' FROM rb_db_lov WHERE key = 'data_timestamp'; +---------------------+ | DB version | +---------------------+ | 2026-10-06 14:30:15 | +---------------------+ -- Parts, which have multiple non-`NULL` image URLs, SELECT dense_rank() OVER (ORDER BY part_num, color_id) '#' , part_num, color_id, img_url, count(DISTINCT set_num) num_sets, set_num 'example set_num' FROM inventory_parts ip JOIN (SELECT part_num, color_id FROM inventory_parts GROUP BY 1, 2 HAVING count(DISTINCT img_url) > 1 -- use this to include null/non-null differences: -- HAVING count(DISTINCT coalesce(img_url, '!')) > 1 ) USING (part_num, color_id) JOIN inventories i ON i.id = ip.inventory_id GROUP BY part_num, color_id, img_url ORDER BY part_num, color_id, img_url; +---+----------+----------+-----------------------------------------------------------+----------+-----------------+ | # | part_num | color_id | img_url | num_sets | example set_num | +---+----------+----------+-----------------------------------------------------------+----------+-----------------+ | 1 | 3820 | 1089 | https://cdn.rebrickable.com/media/parts/ldraw/0/3820.png | 1 | DATABASE-2022 | | 1 | 3820 | 1089 | https://cdn.rebrickable.com/media/parts/ldraw/73/3820.png | 1 | DATABASE-2025 | +---+----------+----------+-----------------------------------------------------------+----------+-----------------+ -- and which have both `NULL` and non-`NULL` image URLs. SELECT dense_rank() OVER (ORDER BY part_num, color_id) '#' , part_num, color_id, img_url, count(DISTINCT set_num) num_sets, set_num 'example set_num' FROM inventory_parts ip JOIN (SELECT part_num, color_id FROM inventory_parts GROUP BY 1, 2 HAVING count(img_url) > 0 AND count(*) > count(img_url) ) USING (part_num, color_id) JOIN inventories i ON i.id = ip.inventory_id GROUP BY part_num, color_id, img_url ORDER BY part_num, color_id, img_url; +----+----------+----------+--------------------------------------------------------------+----------+-----------------+ | # | part_num | color_id | img_url | num_sets | example set_num | +----+----------+----------+--------------------------------------------------------------+----------+-----------------+ | 1 | 11458 | 15 | | 1 | 6650266-1 | | 1 | 11458 | 15 | https://cdn.rebrickable.com/media/parts/elements/6057414.jpg | 161 | 75094-1 | | 2 | 15573 | 15 | | 1 | 6650266-1 | | 2 | 15573 | 15 | https://cdn.rebrickable.com/media/parts/elements/6051511.jpg | 950 | 30286-1 | | 3 | 15573 | 71 | | 1 | 6650266-1 | | 3 | 15573 | 71 | https://cdn.rebrickable.com/media/parts/elements/6066097.jpg | 783 | 75060-1 | | 4 | 15672 | 71 | | 1 | 6650266-1 | | 4 | 15672 | 71 | https://cdn.rebrickable.com/media/parts/elements/6093859.jpg | 226 | 75074-1 | | 5 | 15672 | 272 | | 1 | 6650266-1 | | 5 | 15672 | 272 | https://cdn.rebrickable.com/media/parts/elements/6186683.jpg | 41 | 41187-1 | | 6 | 15712 | 15 | | 1 | 6650266-1 | | 6 | 15712 | 15 | https://cdn.rebrickable.com/media/parts/elements/6054551.jpg | 371 | 10255-1 | | 7 | 18674 | 15 | | 1 | 6650266-1 | | 7 | 18674 | 15 | https://cdn.rebrickable.com/media/parts/elements/6093053.jpg | 518 | 41135-1 | | 8 | 18674 | 272 | | 1 | 6650266-1 | | 8 | 18674 | 272 | https://cdn.rebrickable.com/media/parts/elements/6253885.jpg | 47 | 70826-1 | | 9 | 22885 | 19 | | 1 | 6650266-1 | | 9 | 22885 | 19 | https://cdn.rebrickable.com/media/parts/elements/6214334.jpg | 263 | 10260-1 | | 10 | 2412b | 71 | | 1 | 6650266-1 | | 10 | 2412b | 71 | https://cdn.rebrickable.com/media/parts/elements/4211350.jpg | 884 | 75060-1 | | 11 | 2412b | 272 | | 1 | 6650266-1 | | 11 | 2412b | 272 | https://cdn.rebrickable.com/media/parts/elements/4225575.jpg | 93 | 60096-1 | | 12 | 2540 | 15 | | 1 | 6650266-1 | | 12 | 2540 | 15 | https://cdn.rebrickable.com/media/parts/elements/254001.jpg | 301 | 71217-1 | | 13 | 26603 | 15 | | 1 | 6650266-1 | | 13 | 26603 | 15 | https://cdn.rebrickable.com/media/parts/elements/6156667.jpg | 311 | 41231-1 | | 14 | 2877 | 15 | | 1 | 6650266-1 | | 14 | 2877 | 15 | https://cdn.rebrickable.com/media/parts/elements/287701.jpg | 182 | 10189-1 | | 15 | 3020 | 71 | | 1 | 6650266-1 | | 15 | 3020 | 71 | https://cdn.rebrickable.com/media/parts/elements/4211395.jpg | 1471 | 30300-1 | | 16 | 3021 | 15 | | 1 | 6650266-1 | | 16 | 3021 | 15 | https://cdn.rebrickable.com/media/parts/elements/302101.jpg | 1378 | 850950-1 | | 17 | 3022 | 272 | | 1 | 6650266-1 | | 17 | 3022 | 272 | https://cdn.rebrickable.com/media/parts/elements/4187342.jpg | 160 | 10187-1 | | 18 | 3023 | 15 | | 1 | 6650266-1 | | 18 | 3023 | 15 | https://cdn.rebrickable.com/media/parts/elements/302301.jpg | 2645 | 3931-1 | | 19 | 3023 | 71 | | 1 | 6650266-1 | | 19 | 3023 | 71 | https://cdn.rebrickable.com/media/parts/elements/4211398.jpg | 1787 | 30277-1 | | 20 | 3024 | 15 | | 1 | 6650266-1 | | 20 | 3024 | 15 | https://cdn.rebrickable.com/media/parts/elements/302401.jpg | 1561 | 850950-1 | | 21 | 3069b | 272 | | 1 | 6650266-1 | | 21 | 3069b | 272 | https://cdn.rebrickable.com/media/parts/elements/4205012.jpg | 273 | 75046-1 | | 22 | 3070b | 71 | | 1 | 6650266-1 | | 22 | 3070b | 71 | https://cdn.rebrickable.com/media/parts/elements/4211415.jpg | 627 | 10189-1 | | 23 | 32064a | 15 | | 1 | 6650266-1 | | 23 | 32064a | 15 | https://cdn.rebrickable.com/media/parts/elements/4125562.jpg | 231 | 60034-1 | | 24 | 32316 | 15 | | 1 | 6650266-1 | | 24 | 32316 | 15 | https://cdn.rebrickable.com/media/parts/elements/4140465.jpg | 116 | 75094-1 | | 25 | 3710 | 15 | | 1 | 6650266-1 | | 25 | 3710 | 15 | https://cdn.rebrickable.com/media/parts/elements/371001.jpg | 1881 | 6356-1 | | 26 | 3941 | 14 | | 1 | 6650266-1 | | 26 | 3941 | 14 | https://cdn.rebrickable.com/media/parts/elements/614324.jpg | 283 | 4888-1 | | 27 | 4274 | 1 | | 1 | 6650266-1 | | 27 | 4274 | 1 | https://cdn.rebrickable.com/media/parts/elements/4143005.jpg | 1014 | 4768-2 | | 28 | 43093 | 1 | | 1 | 6650266-1 | | 28 | 43093 | 1 | https://cdn.rebrickable.com/media/parts/elements/4206482.jpg | 2499 | 7899-1 | | 29 | 4697b | 71 | | 1 | 6650266-1 | | 29 | 4697b | 71 | https://cdn.rebrickable.com/media/parts/elements/4211508.jpg | 382 | 5974-1 | | 30 | 54200 | 15 | | 1 | 6650266-1 | | 30 | 54200 | 15 | https://cdn.rebrickable.com/media/parts/elements/4244370.jpg | 957 | 850950-1 | | 31 | 5842 | 15 | | 1 | 6650266-1 | | 31 | 5842 | 15 | https://cdn.rebrickable.com/media/parts/elements/6519989.jpg | 6 | 75419-1 | | 32 | 61332 | 0 | | 1 | 6650266-1 | | 32 | 61332 | 0 | https://cdn.rebrickable.com/media/parts/elements/6279875.jpg | 1232 | 75939-1 | | 33 | 6141 | 0 | | 1 | 6650266-1 | | 33 | 6141 | 0 | https://cdn.rebrickable.com/media/parts/elements/614126.jpg | 1509 | 9385-1 | | 34 | 6141 | 4 | | 1 | 6650266-1 | | 34 | 6141 | 4 | https://cdn.rebrickable.com/media/parts/elements/614121.jpg | 903 | 40107-1 | | 35 | 6141 | 179 | | 1 | 6650266-1 | | 35 | 6141 | 179 | https://cdn.rebrickable.com/media/parts/elements/4633691.jpg | 487 | 75060-1 | | 36 | 67329 | 14 | | 1 | 6650266-1 | | 36 | 67329 | 14 | https://cdn.rebrickable.com/media/parts/elements/6310247.jpg | 76 | 71369-1 | | 37 | 7068 | 15 | | 1 | 6650266-1 | | 37 | 7068 | 15 | https://cdn.rebrickable.com/media/parts/elements/6518048.jpg | 6 | 43266-1 | | 38 | 78258 | 71 | | 1 | 6650266-1 | | 38 | 78258 | 71 | https://cdn.rebrickable.com/media/parts/elements/6436419.jpg | 61 | 75383-1 | | 39 | 79850 | 71 | | 1 | 6650266-1 | | 39 | 79850 | 71 | https://cdn.rebrickable.com/media/parts/elements/6394082.jpg | 6 | 75325-1 | | 40 | 85984 | 15 | | 1 | 6650266-1 | | 40 | 85984 | 15 | https://cdn.rebrickable.com/media/parts/elements/4547489.jpg | 770 | 75094-1 | | 41 | 85984 | 272 | | 1 | 6650266-1 | | 41 | 85984 | 272 | https://cdn.rebrickable.com/media/parts/elements/6216905.jpg | 120 | 75209-1 | | 42 | 98138 | 71 | | 1 | 6650266-1 | | 42 | 98138 | 71 | https://cdn.rebrickable.com/media/parts/elements/4650260.jpg | 687 | 30277-1 | +----+----------+----------+--------------------------------------------------------------+----------+-----------------+