View on GitHub

TSQLBeginners

A TSQL Course for Beginners

TSQL for Beginners

Jump to Section

Course Summary

This free course introduces you to the Transact SQL language implemented in SQL Server and takes you from newbie to a master of SELECT statements. Each session of the course features a demo introducing a subject and a homework assignment to try on your own. The following session covers sample solutions for the homework previously assigned, then introduces a new subject with more homework.

The course covers:

Audience

This course is intended for anyone who wants to learn TSQL. This could be database administrators, developers, business analysts, students, IT support staff, or anyone who is interested to learn a programming language where they can work with sets of data.

Videos

Live classes will air each Wednesday on YouTube, generally at 3PM British Summer Time / 10AM Eastern.

Recordings will automagically appear in this Redgate University Community Circle Course

Course Slack Discussion

Need some help with your homework, or just want to chat with others in the course? You can use this Slack channel to chat while attending a course live, or afterward anytime – don’t worry if you have joined the course late, just start where you are.

  1. Join the SQL Community Slack group for discussion: https://t.co/w5LWUuDrqG
  2. Click the + next to ‘Channels’ and join #tsqlbeginners

Pre-requisites

To get started with the course, you will need to have a couple of applications installed. The course doesn’t show how to install these tools, but jumps right in under the assumption that you have already installed them successfully.

Session Overview

Introducing SELECTs and Aliasing

We cover: Getting going in SQL Server Management Studio or in Azure Data Studio. Using databases. SELECT statements and aliasing. Bonus topic: What does ‘deprecated’ mean?

Follow along with the introductory demo using 1_SelectAndAlias_Demo.sql

Tackle the homework for next session using 2_SelectAndAlias_Homework.sql

Video timeline:

Solutions for SELECT Homework and Introduction to JOINs

We cover sample solutions for ‘SELECTS and Aliasing’, then introduce inner joins outer joins (left, right, full), cross joins.

Sample solutions for ‘SELECTS and Aliasing’ are in 3_SelectAndAlias_Solutions.sql

Follow along with the demo using 4_Joins_DiagramsForHomework.ipynb – this is a Jupyter notebook file which will open in Azure Data Studio

Try your hand at the homework with 5_Joins_Homework.sql

Video timeline:

Solutions for JOINs Homework and Learn GROUP BY and CASE

We step through sample solutions for JOINs homework, then introduce GROUP BY clauses and CASE statements.

Sample solutions for JOINs homework are in 6_Joins_Solutions.sql

Follow along with the demo using 7_GroupingAndCase_DiagramsForHomework.ipynb – this is a Jupyter notebook file which will open in Azure Data Studio

Try your hand at the homework with 8_GroupingAndCase_Homework.sql

Video timeline:

Solutions for GROUP BY and CASE; then CTEs, Subqueries, Derived Tables, Oh My!

We’ll go through sample solutions for the GROUP BY and CASE homework, then dig into differnet ways to nest/combine queries in your queries: Common Table Expressions, Subqueries, and Derived Tables

Sample solutions are in 8_GroupingAndCase_Homework.sql

Follow along with the demo using 9_GroupingAndCase_Solutions.sql

Try your hand at the homework with 11_CTEsSubqueriesDerivedTables_Homework.sql

Video timeline:

Solutions for CTEs and Friends, then Oh No, it’s Scalar User Defined Functions

This time, we talk through sample solutions for the previous week, then give an introduction to making code reusable using functions. We’ll include big-picture information on why functions are controversial in SQL Server and how to be successful with them.

Sample solutions are in 12_CTEsSubqueriesDerivedTables_Solutions.sql

Follow along with the demo using 13_ScalarUDFs_Demo.sql

Try your hand at the homework with 14_ScalarUDFs_Homework.sql

Solutions for Scalar UDFs, then Table Valued Functions and a little CROSS APPLY

We’ll chat through solutions for the Scalar User Defined Function (UDFs) challenges, then I’ll show how Table Valued Functions (TVFs) put the “fun” in functions. No, really, they do! We’ll also cover a bit of CROSS APPLY as we discuss TVFs.

Sample solutions are in 15_ScalarUDFs_Solutions.sql

Follow along with the demo using 16_TVFs_Demo.sql

Try your hand at the homework with 17_TVFs_Homework.sql

Solutions for TVFs, then Ranking, Numbering, and Running Totals with Windowing Functions

We’ll wrap up our discussion of functions by working through the homework, then it’s time for another favorite: Windowing Functions!

Sample solutions are in 18_TVFs_Solutions.sql

Follow along with the demo using 19_WindowFunctions_Demo.sql

Try your hand at the homework with 20_WindowFunctions_Homework.sql

Solutions for Windowing Functions, then Stored Procedures

In our last session, we’ll go through our homework on window functions, then do a gentle introduction to Stored Procedures. Want to try the stored procedure homework yourself before seeing the solutions? Totally fine, you can pause the video at that point.

Sample solutions for Windowing Functions are in 21_WindowFunctions_Solutions.sql

Follow along with the demo using 22_StoredProcedures_Demo.sql

Try your hand at the homework with 23_StoredProcedures_Homework.sql

Sample solutions for Stored Procedures are in 24_StoredProcedures_Solutions.sql