Use db_buiness
Go
Select *from dbo. warehouse WHERE city = ' Beijing '
SELECT DISTINCT (city), warehouse number from dbo. Warehouse//Cancel Duplicate column values
Select SUM (wages) as the total wage from the dbo. Staff
Select warehouse number, city, area from dbo. Warehouse where not city = ' Beijing '
SELECT * from staff where wages between and 1500
SELECT * from staff where sex in (' Male ')
SELECT * from staff where sex is null
SELECT * from staff where name like '% flat% '//% represents multiple characters
SELECT * from worker where name like ' _ ping _ '//underline represents one character
Select Top Ten * FROM dbo. Staff
SELECT * FROM employee ORDER by employee ID
SELECT * FROM Employee ORDER by NEWID ()//newid () random order
Select AVG (Payroll) as average wage from dbo. Staff
Select MAX (payroll) as the highest wage from the dbo. Staff
Select min (wages) as minimum wage from dbo. Staff
Select COUNT (*) as Total records from dbo. Staff
Select COUNT (Distinct (warehouse number)) as Warehouse total from warehouse
Select MAX (Salary)-min (wages) as wage difference from employee
Select warehouse Number, MAX (payroll) as different warehouse maximum wage from employee Group by warehouse number
Select warehouse Number, AVG (payroll) as the average wage for different warehouses from the employee group by warehouse number having AVG (salary) >1000
Select warehouse number, gender, min (salary) as different warehouse minimum wage from employee group by warehouse number, gender
Select Name, SUBSTRING (name, first) as surname, SUBSTRING (name, 2,2) as name from employee
Select warehouse Number, UPPER (warehouse number) as warehouse number uppercase, area from warehouse
Select warehouse Number, LOWER (warehouse number) as warehouse number lowercase, area from warehouse
Select warehouse Number, CONVERT (char (10), creation time, 111) as creation time from warehouse//111 represents date format Yy/mm/dd
SQL Server Query statements