Magic Trick solutions

Magic Trick was solved using SQL by 2 contestants. Solution sizes: average 2251 bytes (shortest: 1099; longest: 3404).