Menu
AVG, MAX, MIN, SUM, COUNT – CREATE DATABASE dbName; GO

AVG, MAX, MIN, SUM, COUNT – CREATE DATABASE dbName; GO

These are some of the most common aggregate SQL functions. You saw them in the previous section. You can use these functions to calculate average, maximum, minimum, and total of numeric column values on one or more tables. The COUNT function returns the number of rows that match the SQL statement criteria. Note that after […]

CONVERT and CAST – CREATE DATABASE dbName; GO

CONVERT and CAST – CREATE DATABASE dbName; GO

CONVERT and CAST are essentially the same—there is no difference between their capabilities or performance. They both exist solely for historical reasons, not for any functional ones. As long as you understand that both of these SQL functions are used to change the data type of data stored in a table, you have this one […]

JOIN – CREATE DATABASE dbName; GO

JOIN – CREATE DATABASE dbName; GO

This is a relational structure‐oriented concept that has to do with querying data that exists in two or more tables using a single query. It is possible to use JOINs on NoSQL data, but the nature of nonstructured or semi‐structured means it won’t be a very performant experience. If the JOIN on non‐ or unstructured […]

Data Manipulation Language – CREATE DATABASE dbName; GO

Data Manipulation Language – CREATE DATABASE dbName; GO

The Data Manipulation Language (DML) category of SQL commands are the ones most used when querying, modifying, and managing data. DML operations are typically executed on rows, columns, and tables. The Data Manipulation Language (DML) consists of the most well‐known SQL commands, like INSERT, UPDATE, DELETE, SELECT, WHERE, SET, and FROM. There are many DML […]

CARTESIAN JOIN – CREATE DATABASE dbName; GO

CARTESIAN JOIN – CREATE DATABASE dbName; GO

A Cartesian JOIN, or a CROSS JOIN, renders a Cartesian product, which is a record set of two or more joined tables. The following snippet is an example of a CROSS JOIN: SELECT [ELECTRODE], [FREQUENCY]FROM [ELECTRODE], [FREQUENCY]ORDER BY ELECTRODE Notice that there is no JOIN condition, which results in each row in the ELECTRODE table […]

UNION – CREATE DATABASE dbName; GO

UNION – CREATE DATABASE dbName; GO

The UNION command combines the data from two or more tables without adding any additional rows. This is best understood visually, so consider the following SQL statement: SELECT SESSION_ID AS ID, CONVERT(VARCHAR(50),SESSION_DATETIME, 127) AS DATE_SCENARIOFROM [SESSION]UNIONSELECT SCENARIO_ID, SCENARIOFROM SCENARIO The result would be something similar to the following. Notice that the rendered output is a […]

DBCC SHOW_STATISTICS – CREATE DATABASE dbName; GO

DBCC SHOW_STATISTICS – CREATE DATABASE dbName; GO

This command will display the current optimization statistics for a table or view. Before you can show the statistics, you first need to create them. The following snippet illustrates how this is done. Provide a statistics name, the table (e.g., READING), and the column (e.g., VALUE) for which you want to capture statistics: CREATE STATISTICS […]