First released four exercises 2333
These problems, we can use the set function is related to the statistical category function
Import:
- If we want to know how the total number of users to do?
- Who is the query data table of the richest man how to do?
- If we want to know the average amount of users how to do?
- If we want to know the total amount of all users how to do?
The most commonly used statistical functions like we have five:
1. The number of elective courses each query
/ * Query the number of elective courses each * / select cno,count(*) from sc group by cno; Who are select, count (sno) from sc group by cno; select cno, count (all cno) / * dbms default Xiabu Qu repeat 2333 * / from sc group by cno;
2. Query enrolled in more than two courses students learn numbers
3.
4.
select sno, count (*) as the number of courses from sc where sno between '1' and '4' group by sno having count(*)>=2 order by count(*) desc; / * Single-table queries, more than * /
Here there are a summary na:
...
Group by group
Result filtered having
The overall use of SQL,
We now after the statement integrate with used once. The grammatical structure of the overall SQL statements used in conjunction with the following:
The final syntax is summarized below:
5.
There are a few statistics courses students take the door .
It is probably one of the selected course many times, so we have to add a keyword distinct deduplication
Relevant information:
Query a single field is not distinct duplicate records
By comparison, it is clear that the role of the distinct look out myself, 2333!
6.
The average age of No. 1 seeking elective courses students
This question needs to really serious about fine chemicals and pondering oh! The first time I did forget to write this condition, when a:
This is equivalent to the natural connection corresponding elective, that is, the natural connection under a certain degree! ! ! ! ! ! ! ! ! !
If it does not increase, then it became a Cartesian product
7. leaving a Questions:
后续再来研究这道题,溜溜溜啦!!!!!!