T-SQL Querying: Writing a SELECT Statement

  • John Deardurff

Your browser needs to be JavaScript capable to view this video

Try reloading this page, or reviewing your browser settings

Autoplay:
View next video

This video provides you with the knowledge to write SELECT statements to retrieve data from a SQL Server database. The video begins with an explanation of fields and records, followed by the anatomy of a SELECT statement. It continues with how to use a WHERE clause to filter specific records into the result set. Since a field can store various data types, the filter section shows how to work with those data types. Finally, there is coverage of how to sort and order a result set.

Also covered is the four-part naming convention for tables in SQL Server. A proper understanding of table naming is important as queries become more involved and complex. Table and column aliases are covered as well, which are names that you can provide as substitutes for canonical names that are often long and cumbersome. Aliases provide a level of insulation in your queries from changes to names in the tables and columns that are being queried.

While this video is about T-SQL and includes examples specific to SQL Server, the bulk of what you will learn is applicable to any vendor’s implementation of the SQL language.

What You Will Learn

  • Query and retrieve data from a SQL Server database

  • Understand the basic structure of a SELECT statement

  • Filter query results to only those records that interest you

  • Sort query results in ascending or descending order

  • Execute queries that answer Top N type business questions

  • Properly reference tables in your queries by using all four parts of a table name

  • Improve readability and maintainability through using alias names

Who This Video Is For

T-SQL Querying: Writing a SELECT Statement is aimed at business analysts, developers, and others whose career will benefit from a knowledge of the SQL language for accessing Microsoft SQL Server databases and the data they contain. The video is for anyone working in a SQL Server environment and wanting to derive business value from their organization’s data by analyzing that data, creating reports, or even generating visualizations.

About The Author

John Deardurff

John Deardurff is a Microsoft Certified Trainer for close to 20 years with experience teaching Microsoft SQL Server, Exchange Server, and Windows Server certification courses. He has also been a database and networking consultant for a majority of that time, and currently holds over 48 Microsoft Certifications. John is an MCT Regional Lead for the Eastern United States, and a Data Platform MVP.

 

About this video

Author(s)
John Deardurff
DOI
https://doi.org/10.1007/978-1-4842-4333-6
Online ISBN
978-1-4842-4333-6
Total duration
48 min
Publisher
Apress
Copyright information
© John Deardurff 2019

Video Transcript

Welcome to this T-SQL Querying video series on writing a SELECT statement. My name is John Deardruff. So to briefly introduce myself, I have been a Microsoft Certified Trainer for the last twenty years. I wan an MVP on Data Platform, and I just recently earned my MBA on IT Management. And as you can also see, I do have quite a few Microsoft certifications.

Now to talk a little bit more about the video course, we’ll start off with this introduction and how to set for the demonstrations for the course. We’ll then talk about fields and records, how to look at fields and records and what they are. Next, we’ll talk about the anatomy of a SELECT statement, how to write your first SELECT statement. Then we’ll discuss the four-part name of a table. And this will not only include the four-part name of a table, but for other objects within SQL server such as views and store procedures.

Next, we’ll include concatenation and aliases within our SELECT statements, and then we’ll have a series of videos on using the WHERE clause, or how to filter out specific records either by numeric field, by character field, by date fields and fields that also have null values or do not have null values. And then finally, we’ll talk about how to use the order by clause to sort our records and then also how to include the TOP values predicate as another way of sorting our records. Then we will have a wrap-up on what we discussed through the video series.

Now before we begin, we do need to make sure we have the correct configuration for demonstrations. To do this, you can visit this link at docs.microsoft.com to get our prerequisites on having a SQL server, downloading the SQL server range for studio, and getting the Adventure Works database that we use for our demonstrations. When you do download the SQL server, we do recommend the evaluation edition when you’re just starting out writing your SELECT statements.

So that is our introduction into the T-SQL Querying video series on writing a SELECT statement. We hope you enjoy it.