SQL Tutorial - Creating a sample of data

Описание к видео SQL Tutorial - Creating a sample of data

Another video brought to you by BeardedDev, bringing you tutorials on Business Intelligence, SQL Programming and Data Analysis.

In this video I talk about how to create a sample set of data to work in Microsoft SQL Server. Creating a sample set of data can be extremely beneficial for development or testing, there is no need to wait minutes or hours for queries to run.

The techniques explored in this SQL Server Tutorial are:
NTILE - if you have are new to working with NTILE check out this video:    • SQL Tutorial - Window Functions - Ran...  
Nested CTEs - if you are new to working with CTEs check out this video:    • SQL TUTORIAL - CTEs Part 1  
Or for a full tutorial on CTEs check out this playlist:
Aggregate Functions - if you are new to working with Aggregate Functions and the GROUP BY clause check out this video:    • SQL TUTORIAL - GROUP BY, HAVING, Aggr...  
SELECT * INTO

SQL Queries in the video:
WITH Number
AS
(
SELECT
CustomerId
, NTILE(1000) OVER(ORDER BY CustomerId) AS N
FROM dbo.Customers
)
,
TopCustomer
AS
(
SELECT
MAX(CustomerId) AS CustId
FROM Number
GROUP BY N
)

SELECT
C2.*
INTO dbo.CustomersSample
FROM TopCustomer AS C1
INNER JOIN dbo.Customers AS C2
ON C1.CustId = C2.CustomerId

SELECT * FROM dbo.CustomersSample

Please feel free to post comments.

Комментарии

Информация по комментариям в разработке