Start learning SQL

Trying to learn SQL? Explore the database world? You will find hundreds of good resources for free at Google University. For beginners, here is what I think will help tremendously. 

Of course, I am making a lot of assumptions here like you already have access to a SQL Server environment and installed SSMS to query databases. 

1) I started with SELECT TOP 10 * FROM when I started my journey. Now I know how consequential it is using *. You can start with basic querying. Learn to SELECT, TOP, DISTINCT, FROM, WHERE, GROUP BY, HAVING, ORDER BY and see what each Keyword does. Be curious to know in what order SQL Engine processes your queries.

2) Aggregate your data. COUNT(*) was obviously my first but then you can expand to SUM(), AVG(), MIN(), MAX(). Leverage GROUP BY and HAVING

3) Now go back and learn about Logical Query Processing Phases. You will enjoy it as I can assure you there will be a bunch of hmm, aaahhhhhaaaa moments. Logical query processing will give you a good understanding of the phases involved in processing a query.

4) Drill that table. Understand Data Types, and learn about Primary Keys, Foreign Keys. Dive a little deeper into Cardinality and you will thank me later. (Hint: Query optimizer depends on cardinality estimates). Start looking into Indexing and Heap

5) Let the fun begin, bring those related tables together. Use JOINs (INNER, LEFT, RIGHT), heck try APPLY operator. UNION, EXCEPT,INTERSET are certainly fun if you remember Set Theory class in middle school math class.

6) It gets exciting when you know you can add, remove, or modify different objects. Yeah, try CREATE, DROP, INSERT, UPDATE, DELETE

7) Window functions will come in handy if you want to perform data analysis. Give it a shot.

Do you know T-SQL statements can be classified into different groups? Let’s review them real quick.

  • DDL – Data Definition Language
    DDL statements define data structures
    • CREATE
    • ALTER
    • DROP
    • TRUNCATE
    • RENAME
    • ENABLE/DISABLE TRIGGER
    • UPDATE STATISTICS
  • DML – Data Manipulation Language
    DML statements affect the data stored.
    • (BULK) INSERT
    • UPDATE
    • DELETE
    • MERGE
    • SELECT
  • DCL – Data Control Language
    DCL statements affect access to data
    • GRANT
    • REVOKE
    • DENY
  • TCL – Transaction Control Language
    TCL commands manage transactions in the database
    • COMMIT
    • ROLLBACK
    • SAVEPOINT