Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

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!

share|improve this question
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
add comment

closed as not constructive by Nick Chammas, a_horse_with_no_name, Thomas Stringer, Mark Storey-Smith, Martin Smith Mar 16 '12 at 10:01

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.If this question can be reworded to fit the rules in the help center, please edit the question.

1 Answer

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

share|improve this answer
add comment

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