select statement
Columns from the data table Select query fields to be queried indicate where the search condition group by group having sort order by clause
* Indicates that the query all the fields
This SELECT 12 * 13 * 13 12 query results, but the results are not returned to the column name (Figure 1)
If so he has a column name can be added as a column name (result Figure II) in the back
Select 12*13 as 计算结果
Select 姓名 as 学生姓名,性别 from 学生信息
This line of code check out the results, the column name will be changed to the student column student's name,
If there are a lot of inquiries from ethnic duplicate values, and we just want to know how many different ethnic groups, you can use the following code. This statement returns the different peoples.
select distinct 名族 from 学生信息
Sort query results
Select * from 成绩信息 where考试编号=‘0801’ and 课程编号=‘1’ order by 分数,学生编号 asc
The default is asc ascending descending order if you want to change the asc desc
For there may be different when the same test scores sorted student test scores, the case may arise out of order
Select * from 成绩信息 where考试编号=‘0801’ and 课程编号=‘1’ order by 分数desc,学生编号 asc
This is the first of scores in descending order, if the score duplicate values, students will be numbered in ascending order.
having clause
The following code is selected grades for all courses in grades> 90 information
Select 学生编号,课程编号,avg(分数) from 成绩信息 group by 考试编号,课程编号 having avg(分数)>90 order by考试编号