Builds the final SQL query based on the builder's state. Must be implemented by each concrete builder class.