Tag Archive

Tag Archives for " SQL 101 "

How to use the Choose Function with Select

In this video we’ll walk you though how to use the CHOOSE function with SELECT. You’ll see how the function works and then a practical example using some sample data. Once you’ve gone through this article, I would recommend watching our next Essential SQL Minute to continue learn more about SQL Server! Once you have […]

Continue reading

How to use the BETWEEN operator to compare a range of values in SQL SERVER Queries

In this video we’ll walk you though how to use the BETWEEN operator; we’ll show you why you would want to use the BETWEEN operator and how to avoid pitfalls when using it with the DATETIME type. The BETWEEN operator is equivalent to using AND combination of >= and <= comparison operators, but makes for […]

Continue reading

What is the difference between a primary and unique key?

Primary and Unique Key

In this article we learn the difference between a primary and unique key, and why both are important to maintaining a relational database structure. All the examples for this lesson are based on Microsoft SQL Server Management Studio and the AdventureWorks2012 database.  You can get started using these free tools using my Guide Getting Started Using SQL […]

Continue reading

Uncommon SQL Server Data Types

In this article we’re going to go over a uncommon SQL server data types.  These are those you won’t use every day, but you’ll want to know if you take the 70-461 exam. Even if you don’t plan on taking the 70-461, learning these data types is fun, especially the spatial datatype (I had no idea […]

Continue reading
1

Know when to use Cast versus Convert

In this article we’re going to explore the CAST and CONVERT functions to understand whether there are any significant differences worth knowing when we want to convert data from one type to another. Since CAST and CONVERT can be used interchangeably in most situations, you may be wondering if one is better than the other. […]

Continue reading
1

Learn to use SQL Server Date Functions

SQL server’s date functions provide you a set of function that you can use to manipulate dates.  The function are used for a wide variety of operation such as adding weeks to a date, calculating the difference between two dates, or to decompose a date into its fundamental parts. If you not familiar with SQL […]

Continue reading

Introduction to SQL Server’s Common String Functions

The built in SQL String functions make it possible for you to find and alter text values, such as VARCHAR and CHAR datatypes, in SQLServer.  Using these functions you can alter a text value such as changing “Smith, Joe” to “Joe Smith.” If you not familiar with SQL functions, then I would recommend staring with […]

Continue reading

Introduction to SQL Server’s Mathematical Functions

Mathematical Functions to Old Way - Slide Rule!

Math Rocks! SQLServer includes many mathematical functions you can use to perform business and engineering calculations.  Many of these aren’t used in typical day-to-day operations; however, there are several commonly used functions we’ll cover. If you not familiar with SQL functions, then I would recommend staring with the Introduction to SQL Server Built-In Functions. All […]

Continue reading

Introduction to SQL Server’s Built-In Logical Functions

Logical Circuit

Logical functions provide a way to use logical conditions to display one of several values.  You can use logical functions to test a field’s value such as gender (M or F) and display another value(‘Male’ or ‘Female’) as a result. In this article we describe how to use the CHOOSE and IIF functions.  CHOOSE is […]

Continue reading

Built-In Functions (SQL Server)

Built in SQL Functions

Built-In functions are used in SQL SELECT expressions to calculate values and manipulate data.  These functions can be used anywhere expressions are allowed.  Common uses of functions include to change a name to all upper case.  In this article we’ll introduce you to basic concepts. All the examples for this lesson are based on Microsoft […]

Continue reading
3

Converting Between Data Types with SQL Server Functions

SQL server uses data types to store a specific kind of value such as numbers, dates, or text in table columns and to use in functions, such as mathematical expressions. One issue with data types is that they don’t usually mix well.  Conversion functions make them mix better! Though there are time when types are […]

Continue reading

Using Conditional Logic in SQL with CASE Expression

Kings Chapel College

The main purpose of a CASE expression is to return a value based on one or more conditional tests.  CASE expressions can be used anywhere in a SQL statement an expression is allowed. Though a truly an expression, some people refer to them as “CASE statements.”  This most likely stems from that use of the […]

Continue reading
3

How do the SQL DISTINCT and TOP SELECT Clauses Work Together to Generate Results?

Distinct pattern of terminals

This article is inspired by a series of questions that one of my readers, Nan, recently sent me regarding DISTINCT, TOP, and ORDER BY. All the examples for this lesson are based on Microsoft SQL Server Management Studio and the AdventureWorks2012 database.  You can get started using these free tools using my Guide Getting Started Using […]

Continue reading

What is the difference between WHERE and HAVING clauses?

In this article learn when to use WHERE and HAVING.  Both perform similar functions, but for different purposes! All the examples for this article are based on Microsoft SQL Server Management Studio and the AdventureWorks2012 database.  You can get started using these free tools using my Guide Getting Started Using SQL Server. How do Where and Having Differ? […]

Continue reading
2

What is the Difference between ORDER and GROUP BY?

Differences in Order By versus Group By

The GROUP and ORDER BY clauses are both used to organize data.  Learn which is used to sort the data, and which is used for counting and summing. All the examples for this lesson are based on Microsoft SQL Server Management Studio and the AdventureWorks2012 database.  You can get started using these free tools using […]

Continue reading
8

Use SQL Server to Sort Alphanumeric Values

Sort Alphanumeric Values with SQL Server Recently a reader asked me how to sort an alpha numeric field in SQL in natural order.  Alphanumeric values are commonly found and don’t sort naturally using numeric methods. When we have a numeric fields we expect values to be sorted in ordinal order, for example: 1,2,5,7,10,11,15,20,21 However when […]

Continue reading

What is a Database NULL Value?

Null and unknown values

What is a Null Value? In databases a common issue is what value or placeholder do you use to represent a missing values.   In SQL, this is solved with null.  It is used to signify missing or unknown values.  The keyword NULL is used to indicate these values.  NULL really isn’t a specific value as much as it […]

Continue reading
2

How to Use GROUP BY to Summarize Query Results

Group and Summarize Data

In today’s lesson you’re going to learn about grouping results returned from your queries using the GROUP BY clause. The objectives of today’s lesson are to: Learn how to group results using GROUP BY Use aggregate functions to perform calculations Understand how to filter groups using the HAVING clause Important! Please follow along and do the […]

Continue reading
2

Use Pattern Matching in SQL to Filter Results

In this lesson you are going to explore how to use pattern matching in SQL with the LIKE operator.  Using this phrase allows us perform partial matches of data values and obtain answers to questions which can’t be done with conventional comparisons. The lesson’s objectives are to: learn about the LIKE match condition understand wild cards Important! Please follow […]

Continue reading
4

Query Results Using Boolean Logic

Old Fashioned Computer

In today’s lesson you’re going to learn how to query results using the WHERE clause. The objectives of today’s lesson are to: Learn to use more than one compare condition at a time using Boolean logic Comprehensive example with Select, Where, and Order By   Using Multiple Conditions to Query Results In previous lesson’s we learned how […]

Continue reading
3

Get Ready to Learn SQL Server:  4. Query Results Using Boolean Logic

In today’s lesson you’re going to learn more about filtering results returned from your queries using the WHERE clause. The objectives of today’s lesson are to: Learn to use more than one compare condition at a time using Boolean logic Comprehensive example with Select, Where, and Order By Important! Please follow along and do the examples […]

Continue reading

How to Filter Query Results

Where Clause

In today’s lesson you’re going to learn how filter the results returned from your queries using the WHERE clause.  This clause is important as only those records matching the where clause’s conditions are returned in the query results. The objectives of today’s lesson are to: Learn about various condition types, such as Equality, Range, and […]

Continue reading
2

How to Filter Query Results

In today’s lesson you’re going to learn how to filter query results using the WHERE clause.  This clause is important as only those records matching the where clause’s conditions are returned in the query results. The objectives of today’s lesson are to: Learn about various condition types, such as Equality, Range, and Membership Comprehensive example […]

Continue reading
4

What are the Major Part of a SQL DB?

Parts of a Database

A SQL database is used to store and retrieve data.  The database is housed in a database server and largely controlled by a database management system.  All SQL databases, whether they MS SQL Server, MySQL, Oracle, or Progress have several components in common.  They are: Tables Indexes Views Stored Procedures Triggers It is these various […]

Continue reading
9

Getting Started With SQL Server: 2. Sort Your Query Results

In this lesson you are going to explore how to sort your query results by using SQL’s ORDER BY statement.  Using this phrase allows us to sort our result in ascending or descending order.  In addition you can limit your query to a specified number of results. The lesson’s objectives are to: learn how to sort on […]

Continue reading

Learning SQL

Recently I had a chance to ask Allen Taylor questions about learning SQL and his perspective on the learning and using the language.  Allen has worked with computer for over thirty years, and brings a wealth of experience to the table.  Allen has written many books on databases and frequently lectures.  Please be sure to […]

Continue reading
7

Getting Started with SQL Server: 1. Simple SELECT Queries

In this series of lessons you’re going to learn how to query Microsoft SQL Server using the SQL SELECT statement.  Once you have read this lesson you’ll be able to: Identify all the tables in a SQL Server Database Using SSMS (SQL Server Management Studio). Understand how to list a table’s columns. Use the SQL SELECT statement to view […]

Continue reading