Menu
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 […]

DISTINCT – CREATE DATABASE dbName; GO

DISTINCT – CREATE DATABASE dbName; GO

Using the DISTINCT command eliminates duplicate records from your SQL queries. The following query will return all rows from the SESSION table. Assume that the SCENARIO_ID of 1, which is the ClassicalMusic scenario, exists multiple times. In that case all rows are returned, in addition to all other SCENARIO_IDs. SELECT [SCENARIO_ID] FROM [dbo].[SESSION] If you […]