FunToMakeAWebsite.com

 

contenttitleicon SQL

SooBest

SQL syntax SQL Functions
SQL Alter
SQL Date Functions
SQL Create DB

SQL Getdate()
SELECT getdate();

SQL Create Table

SQL Dateadd()
SELECT dateadd(D, -5,GETDATE());
D,DAY,DAYOFYEAR,DD,DW,DY,HH,HOUR,M, MI, MICROSECOND, MILLISECONDS, MINUTE, MM, MONTH,Q,QQ, QUARTER,S, SECOND, SS, W, WEEK, WEEKDAY, WK, WW, Y, YEAR, YY, YYYY

SQL Delete

SQL Datepart()
SELECT datepart(D, getdate());

 

SQL Convert()
SELECT convert(date, getdate());

SQL Distinct

SQL Datediff()
SELECT DATEDIFF(day, ’2016-04-31’, ’2016-05-31’)
D,DAY,DAYOFYEAR,DD,DW,DY,HH,HOUR,M, MI, MICROSECOND, MILLISECONDS, MINUTE, MM, MONTH,Q,QQ, QUARTER,S, SECOND, SS, W, WEEK, WEEKDAY, WK, WW, Y, YEAR, YY, YYYY

SQL Full Join

SQL First Day of last month
SELECT DATEADD (month, DATEDIFF(month, 0, getdate())-1,0)

SQL Last Day of last month
select DATEADD(ss, -1, DATEADD(month, DATEDIFF(month, 0, getdate()), 0))

SQL Insert Into

SQL First Day of this month
SELECT DATEADD (month, DATEDIFF(month, 0, getdate()),0)

SQL Last Day of this month
SELECT DATEADD(s,-1,DATEADD (month, DATEDIFF(month, 0, getdate())+1,0))

SQL Insert Into Select
SQL Join
SQL String Functions
SQL Left Join
SQL Substr()

SELECT SUBSTRING('EFGHI', 2, 3);

SQL Select Into
SQL Select TOP
SQL Union
SQL Update
SQL Numeric Functions
SQL View
SQL AVG()
SELECT AVG(TotalPayment) as PaymentAVG
FROM Category
SQL Widecards
SQL Count(Distinct )
SELECT Count(Distinct Item_Number) as ItemDistinctCount FROM Items;
SQL