Test SQL creation logic for plots