org_id org_name bldg count 21 Bridgton, Town of 2 - buildings has 4 in test 48 NHSAU 18 x5 53 NHSAU 36 - White Mountains Regional School Dist 6 4 NHSAU 03 - Berlin Public Schools 7 49 NHSAU 30 - Laconia School District 8 97 SU 36 Rutland NE 9 58 NHSAU 57 - Salem x9 - - buildings has 8 in test 15 AOS 91 - MDIRSS x11 112 Rochester, City Of x12 96 Essex Westford School District 13 - - MA has 14 57 NHSAU 54 - Rochester School Dept x15 55 NHSAU 42 - Nashua School District 21 65 Norway Savings Bank x25 SELECT COUNT(bldgs.id) bCnt, org_id, org.org_name FROM buildings bldgs INNER JOIN organization org ON org.id = org_id GROUP BY org_id ORDER BY bCnt DESC; For org Id 96 there are records for Essex Junction Rec (buildings.id = 561) The org_id for this building is null in buildings. It should be set to 96. /*Test has this belonging to org_id 96 */ SELECT * FROM buildings WHERE id = 561; /*I DID update this org_id #UPDATE buildings SET org_id = 96 WHERE id = 561;*/ /*Test has 17 records for 561 */ SELECT * FROM Machine_Archive WHERE building_id_ma = 561; /*Nothing in this table in prod or test for 561 */ SELECT * FROM current_devices WHERE building_id_ma = 561;