SQL query Statements

Source: Internet
Author: User

I learned SQL query statements at Cloud and college today.

Query statements

Select field name from table name where condition (condition can not be written)

Example: select name, gender, salary from dbo. Staff

If all fields are available * instead

where represents the query condition

Select name, gender, salary from dbo. Staff where gender = ' male ' and salary not between 2500

Delete from T1

Delete Deletes the record in the table, the table exists
drop table T1

drop table to delete the structure and contents of tables

Select COUNT (Distinct (warehouse number)) as warehouse number from staff

Select SUM (wages) as the total wage from staff

Select MAX (payroll) as highest wage from employee

Select min (wages) as minimum wage from staff

Select AVG (payroll) as average salary from staff

Count is count, sum sum, max Max, Min Min, avg averaging

There are two types of SQL annotations:

One is to use--

The second is to use/**/

Between and indicates in what interval

Like Fuzzy Lookup

Select warehouse Number, MAX (payroll) as different warehouse maximum wage from employee where sex! = ' woman ' GROUP by warehouse number

Where is used with the group by keyword, where filters the data before grouping

Having a data filter after grouping the Select warehouse number, AVG (payroll) as different warehouses of goods are paid from the employee group by warehouse number having AVG (salary) >1700

Group BY is a group

Select name, gender, salary from employee order by sex, payroll desc

Order BY IS sort

UPDATE statement

Update warehouse set area =950 where city = ' Jinan '

SELECT DISTINCT (city) from dbo. Warehouse--Remove Duplicate column values

Select warehouse Number, CONVERT (char (10), creation time, 111) as creation time from warehouse

Time Format:

SQL query Statements

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.