SQL 2012 Developer, Part 11 of 13: Complex Querying
Interactive

SQL 2012 Developer, Part 11 of 13: Complex Querying

LearnNow Online
Updated Aug 22, 2018

Course description

We’ll start off by discussing the specifics of a topic you might not expect—handling NULLs! I know it sounds surprising, but it’s important to really understand how to work with NULL values—especially if you plan to integrate with the Common Language Runtime. Next, we’ll address another common and seemingly straightforward task—the ranking of data. We’ll explore the specifics of how to rank grouped data using some T-SQL functions including ROW_NUMBER, RANK, DENSE_RANK, and NTILE. Next we’ll take a look at how to identify correlated subqueries and how you can possibly replace them with more efficient constructs. Finally, we’ll look at an alternative to subqueries, derived tables, and temporary tables—known as Common Table Expressions, or CTEs, they are similar to derived tables but they are self-referencing, can be used numerous times within the same query, and can be called recursively!

Each LearnNowOnline training course is made up of Modules (typically an hour in length). Within each module there are Topics (typically 15-30 minutes each) and Subtopics (typically 2-5 minutes each). There is a Post Exam for each Module that must be passed with a score of 70% or higher to successfully and fully complete the course.


Prerequisites

This course assumes that you have a basic familiarity with the concept of relational databases and a basic understanding of what SQL Server is and the high-level tools in it, as well as how to create and manage objects using Management Studio. You should also have a basic understanding of how SQL Server implements security, including its authentication and authorization schemes, and how to assign permissions on securable objects to principals. You should know the fundamentals of Transact-SQL to write queries to retrieve and update data, and how to execute scripts using the query editor in Management Studio. It will be very helpful, but not absolutely necessary, to have experience with .NET development using Visual Studio 2010 or 2012 for the portions of the course that deal with SQLCLR development. The .NET code included in this course is written in C#, but if you prefer Visual Basic it should be fairly easy to convert the code.


Meet the expert

Frank Tillinghast

Frank Tillinghast is a senior consultant with MTOW Software Solutions. He is a Microsoft Certified Solution Developer and has been developing applications for over 15 years. Most of his time is spent consulting for companies nationwide with troubled projects or mentoring projects to successful completion. When he is not developing software or mentoring clients, Frank is teaching other developers. He has taught thousands of application developers how to create business solutions with Visual Studio .NET. VB.NET, ASP.NET, Visual C#, and SQL Server.

Video Runtime

75 Minutes

Time to complete

282 Minutes

Course Outline

Complex Querying

Complex Querying (22:21)

  • Introduction (00:28)
  • Working with NULL Values (00:16)
  • SqlTypes and CLR Types (04:18)
  • Demo: NULLs (03:03)
  • ANSI_NULLS (03:19)
  • Demo: ANSI_NULLS (02:08)
  • NULLs and SqlBoolean (01:15)
  • Assigning NULL Values (00:27)
  • CLR Integration (00:19)
  • Direct Assignment (00:32)
  • NULLIF (00:42)
  • COALESCE (00:34)
  • Demo: NULL Functions (02:50)
  • Demo: NULL Value Assignment (01:43)
  • Summary (00:21)

Rankings (14:47)

  • Introduction (00:27)
  • Ranking Grouped Data (00:49)
  • The ROW_NUMBER Function (02:19)
  • The RANK Function (01:33)
  • DENSE_RANK Function (00:50)
  • The NTILE Function (02:32)
  • Demo: ROW_NUMBER (01:41)
  • Demo: RANK (01:31)
  • Demo: DENSE_RANK (00:51)
  • Demo: NTILE (01:56)
  • Summary (00:13)

SubQueries (21:06)

  • Introduction (00:27)
  • Writing Correlated Subqueries (00:41)
  • Subquery Basics (01:07)
  • What is a Correlated Subquery? (00:45)
  • Demo: Subqueries (03:28)
  • Using the WHERE Clause (01:47)
  • ANY, SOME, and ALL Modifiers (00:47)
  • Including the HAVING Clause (00:37)
  • Subqueries and Updates (00:31)
  • Demo: ALL Modifier (01:23)
  • Demo: HAVING Clause (04:06)
  • Joins and Temp Tables (02:21)
  • Demo: Replacing a Subquery (02:43)
  • Summary (00:17)

Common Table Expressions (17:20)

  • Introduction (00:34)
  • Using Common Table Expressions (01:26)
  • CTE Syntax (00:56)
  • Demo: Common Table Expression (02:54)
  • Recursive CTEs (05:23)
  • Demo: Recursive CTEs (04:08)
  • Demo: Executing a Recursive CTE (01:42)
  • Summary (00:15)