MySQl or SQL Server?
Answering for MySQL:
P: Even if there is no GROUP BY clause in a SQL query, it can have a HAVING clause.
Syntactically, HAVING must follow GROUP BY. If there is no GROUP BY, then you're aggregating at the table level, so WHERE conditions do exactly the same job.
Q: If a SQL query has a GROUP BY clause, it can only have a HAVING clause.
You can have both WHERE and HAVING clauses.
R: The SELECT clause must include all attributes used in the GROUP BY clause.
you tell MySQL that you really do want to do stupid things with your aggregate queries and allow yourself to write queries that every other DBMS will arbitrarily throw out the window.
S: The SELECT clause does not have to include all of the attributes used in the GROUP BY clause.
False ... unless... See previous answer.
of these have anything to do with Query Optimisation
- more a basic understanding of SQL syntax.