SQL Server Query statements

Source: Internet
Author: User
Tags sql server query

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.