
Join this course to learn SQL Server queries from the ground up, covering select, from, where, order by, group by, and bonus modules on stored procedures and user defined functions.
Learn how to select from a table using select star to retrieve all fields in schema order, or name and reorder fields, and pick only the ones you need.
Count rows with select count(*) from a table and compare total rows to filtered results with a where clause, naming the count column with an alias.
Discover how to use the sum function to total salaries, group results by department, and join employee and department data for meaningful payroll insights.
Learn how to use the max aggregate function to find the highest salary in an employee table, and explore field aliasing and optional square bracket syntax in SQL queries.
Learn how to use the min function to find the smallest salary from the employees table, including wrapping the field in square brackets to handle reserved names.
Explore min and max functions by querying an employee salary table to reveal lowest and highest salaries, and learn to name results with square brackets where as is optional.
Explore the average function in sequel server by selecting salaries from the employee table, computing the average as an aggregate function, and naming the result with square brackets.
Learn how to concatenate first and last names in SQL, using plus signs and spaces, alias the result as name, and cast numbers to text when combining fields.
Learn how to use the case statement in SQL to label six-figure salaries, select first name, last name, and salary, and populate a notes field with conditional notes.
Apply the select case statement and concatenating text in SQL to combine first and last names, and label salaries as six figures or jackpot when thresholds are met.
Explore the from clause and how to pull records from one or more tables, then learn how inner and left joins connect related data efficiently.
Learn how to query related data from two tables using inner join and left join, and why using on conditions with a where clause ensures correct matches.
Learn how to perform an inner join between employees and departments, selecting employees' first and last names and the department name, using alias prefixes to avoid ambiguity.
Learn how a left join combines all employees with their departments, returning matching department data where available and including all employee records.
Explore the difference between left join and inner join in SQL by linking the employees and department tables with primary and foreign keys, showing matches and unmatched left rows.
We compare left join and right join, showing how they produce the same results when switching table order, and how inner joins differ by returning only matching records.
Perform an inner join using a temp table with employees and departments, selecting first name, last name, and the full department name.
Learn how to perform an inner join with a table variable to connect employee and department data, declare and populate the variable, and select from it instead of real tables.
Learn how to build union queries in T-SQL to combine employee data from different databases, align fields, optionally concatenate names, and display salaries from highest to lowest.
Explore using the where clause to filter records in SQL queries. Apply operators equals, less than, greater than, between, and in, and combine conditions with and, or, and parentheses.
Learn how to use the equals operator to filter employees by numeric and text fields, wrap text in single quotes, and preview simple joins.
Learn to filter salary data in SQL Server using comparison operators—greater than, less than, equals, greater than or equal to, less than or equal to—and the between range to write concise queries.
Learn how to filter records using the IN operator in SQL, selecting departments 3 or 4 from the employee table and handling text with single quotes.
Learn to use the between keyword to define a range, such as salary between 98 and 110, for clearer and more concise SQL queries.
Explore using in and not in with a sub query on the Acme database, selecting employees by department and applying dynamic not in examples to filter results.
Explore the difference between using the in clause and a subquery to filter employees by department, highlighting dynamic lookups versus hard-coded values for robust sql querying.
Explore using the where and operator with the datepart function to filter employees by hire year, and combine department and year conditions for readable sql queries.
Examine how the or operator differs from and in SQL Server, using datepart to extract years, filtering employees by department or hire year, and understanding when or expands results.
Sort customer data with order by using ordinals or field names to group by state and city, then order by name, and learn ordinals, default ascending, and common pitfalls.
Ordering by ordinals saves typing, but altering the select list or removing fields can break the sort or cause out-of-range errors. Use ordinals only for permanent fields or dropdown data.
This video will discuss the importance of being familiar with ASCII values and how htis ties in with the ORDER BY Clause.
You really need to watch this video along with the next video, about COLATION to get the entire message.
This video will discuss the importance of being familiar with "COLATION" and how this ties in with the ORDER BY Clause.
You really need to watch this video along with the previous video, about ASCII values to get the entire message.
Learn how to use the descending keyword to sort results, see examples sorting by state, and apply order by to view newest records or per-department salary rankings.
Learn how to order results with an order by case expression to prioritize New York records in a single query, contrasting simple two-query methods with a more efficient approach.
In this video we continue on with a strange ordering request: "Put NY first, then all other states in order." This video shows a specific approach that works but is more complicated than what is necessary.
Learn how the group by clause uses aggregate functions like min, max, and count to summarize customers by last name and their largest order total.
Grouping by last name consolidates data and enables you to compute max total and min total, then derive the spread for quick reports.
Explore the count function with group by to tally records per customer last name in the sales order table, and order results by the second field.
Apply the sum function to a query, add a sum field, show total dollar amount and record counts, and order customer names by the sum field in descending order.
Learn to use sql's average function with group by to compute per-customer averages, alongside sum and count, for financial reports.
Explore how to use group by with the having clause to filter aggregated results, such as showing customers who spent over $2000 or exceeded sales counts.
GROUP BY - HAVING CLAUSE - Part 2
Master group by and having to sum the total field and filter customers with total greater than or equal to 2000, and compare having with group by and order by.
xxx
Stored procedures populate dropdowns and keep sql logic centralized, avoiding code changes. Filter visible = 1 to hide inactive customers, updating the dropdown without recompiling client applications.
VIDEO - The video will show you how to write to a text file from SQL Server.
The following notes are references to the additional support files that are connected with this section. These files are downloadable so that you can copy and paste the code right into SSMS / T-SQL.
01 - CREATE PROCEDURE Write To File - This is the TSQL code to create your own [WriteToFile] STORED PROCEDURE.*
02 - Write To Text File - Command Line SQL - This is an example of how to EXECUTE the [WriteToFile] STORED PROCEDURE.*
03 - Write To Text File Command Line SQL - With Parameters - This is an example of how to EXECUTE the [WriteToFile] STORED PROCEDURE - with Parameters/Variables/Arguments.*
04 - Write To Text File Command Line SQL - With Parameters And Date In Filename - This is an example of how to execute the [WriteToFile] STORED PROCEDURE - with Parameters/Variables/Arguments and INSERTING a FORMATTED DATE-TIME STAMP into the file name.*
Ole Automation SQL - This is the code that you will need to run to initially turn on the OLE AUTOMATION Permissions in SQL SERVER.*
* This T-SQL code can be copied into the SSMS command line environment.
Discover user defined functions in SQL, name and call them with parameters, and see text manipulation examples like concatenation and leading zero padding used for sample IDs.
VIDEO- The video will show you how to make use of a User Defined Function. In this particular example the function will return a value that has been formatted with n instances of a specific text character.
The following notes are references to the additional support files that are connected with this section. These files are downloadable so that you can copy and paste the code right into SSMS / T-SQL.
01 - CREATE FUNCTION – dbo.PrePad() Example- This is the TSQL code to create your own dbo.[PrePad]USER DEFINED FUNCTION.*
02 – USER DEFINED FUNCTION – dbo.PrePad() Example- This is an example of how toCALL / USE the dbo.[PrePad]USER DEFINED FUNCTION.*
* This T-SQL code can be copied into the SSMS command line environment.
Learn to use a user defined function in a real-world sql example, including scalar valued functions, owner qualification, and a prepared function that pads order numbers to six digits.
This is an in depth course about using and programming with SQL Server. It assumes that the student has at least a rudimentary understanding of database concepts and architecture and gets right into the meat of the subject.
This course will get you up to speed on executing queries. The final part of the course briefly touches on stored procedures and user defined functions.