USE salesdb;
SELECT TOP 15 * FROM Customers;
--https://docs.microsoft.com/en-us/sql/azure-data-studio/notebooks/notebooks-sql-kernel
--SELECT distinct Title FROM Person.Person
--SELECT distinct Type, Category FROM Sales.SpecialOffer
SELECT distinct size, color from Production.Product
SQL Server Coding (Direct copied from Azure Data Studion After executing output got there then pasted here)
Data Types
Date Datatype
Declare @myDate date = '02-02-2016'
Select @myDate as MyDate
Declare @myDateTime datetime = '02-02-2016'
Select @myDateTime as MyDateTime
Declare @myTime time = '16:25:42.1214'
Select @myTime as MyTime
Declare @myTime time(2) = '16:25:42.1214'
Select @myTime as MyTime
![]() |
Charecter Datatype
![]() |
![]() |
![]() |
-- Character
DECLARE @myChar CHAR(20) = 'PDI'
SELECT @myChar AS Char, DATALENGTH (@myChar) as Datalength, LEN(@myChar) AS Len
-- Varchar
DECLARE @myChar VARCHAR(20) = 'PDI Lmtd'
SELECT @myChar AS Varchar, DATALENGTH (@myChar) as Datalength, LEN(@myChar) AS Len
Numeric Datatype
![]() |
![]() |
![]() |
DECLARE @num NUMERIC(7,2) = 12376.7854
SELECT @num as NumericData
DECLARE @SmallInt SMALLINT = 12376.7854
SELECT @SmallInt AS SmallIntData
-- DECLARE @SmallInt SMALLINT = -32769
-- SELECT @SmallInt AS SmallIntData
-----------------Errors when we un comment above and run codes
-- if we give more/less than
--affordable range it will gives an error
--Msg 220, Level 16, State 1, Line 1
--Arithmetic overflow error for data type smallint, value = -32769.
DECLARE @TinyInt SMALLINT = 254
SELECT @TinyInt AS TinyIntData
![]() |
![]() |
--Float
DECLARE @float FLOAT(10) = 12376.7854
SELECT @float as FLOAT
--Data type precedence
DECLARE @float1 FLOAT(10), @int INT
SET @float1 = 12376.7854
SET @int = 570
SELECT @float1 + @int as Result
Filter the data using where
USE AdventureWorks2014;
SELECT TOP 10 * FROM AdventureWorks2014.HumanResources.Employee WHERE SickLeaveHours > 50;
SELECT TOP 10 * FROM Sales.CreditCard WHERE ExpYear = 2008;
USE Training
-- selecting products table
SELECT * FROM products;
-- selecting city table
SELECT * FROM city;
SELECT * from City;
Use Training;
SELECT *
from City where populationDensity = 'High';
SELECT *
FROM City WHERE PopulationDensity = 'High'
SELECT
MIN([DATE_KEY]) AS [MIN_DATE],
MAX([DATE_KEY]) AS [MAX_DATE],
YEAR, MIN([DATE_KEY]), MAX([DATE_KEY])) [SPAN_IN_YEARS]
DATEDIFF(FROM [EDW].[F_COLLISIONS]
DECLARE @myDate date = '02-02-2016';
SELECT @myDate as MyDate;
DECLARE @myDate datetime = '02-02-2016';
SELECT @myDate as MyDate;
No matching items