0

I've recently began learning T-SQL and have found that there are some rules to using single table queries. For instance:

GROUP BY

If aggregate and non-aggregate expressions are used together in a SELECT statement, the GROUP BY clause must be used.

HAVING

The HAVING clause is generally used with GROUP BY

TOP

The TOP statement relies on the ORDER BY clause for logical precedence among rows

ORDER BY

Data returned when using an ORDER BY clause results in a cursor, whereas a table result is returned when not using the ORDER BY clause

I was curious if anyone else had any tips for learning the relationships among the different DML statements.

Thanks in advance!

  • 1
    This question is too broad for the Stack Exchange format. If you narrow it down to a specific aspect of T-SQL we can better help you. – Nick Chammas Mar 15 '12 at 22:10
  • The resources for deep learning of SQL are discussed here: dba.stackexchange.com/questions/14757/… – Alex_L Mar 15 '12 at 22:36
  • Thank you all for your helpful responses. I will continue to read and take more notes. – matrixx333 Mar 15 '12 at 23:44
1

As @Nick suggested, this question is too broad to have straight forward answer. Are you looking for how to write queries ?? Or you are looking for commonly used best practices for any query ?? Or something else ?? May be for starter you can google around this question, or look at some of the following sites,

http://blog.sqlauthority.com/2009/01/20/sql-server-rules-for-optimizining-any-query-best-practices-for-query-optimization/

http://www.databasejournal.com/features/mssql/article.php/3827091/T-SQL-Best-Practices.htm

http://www.sql-server-performance.com/2001/sql-best-practices/

http://www.codeproject.com/Articles/34372/Top-10-steps-to-optimize-data-access-in-SQL-Server

Not the answer you're looking for? Browse other questions tagged or ask your own question.