Make SQL parts have newline prefix instead of newline suffix
Add test for aggregation