1.GROUP BY的使用注意事项
SELECT后面没有使用聚合函数的列,必须出现在GROUP BY的后面
select Email
from Person
group by Email // 这里必须出现
having count(*) > 1
2.SELECT多个表是什么意思??
内连接
已知一个表的结构为:
-------------------
姓名 科目 成绩
张三 语文 20
张三 数学 30
张三 英语 50
李四 语文 70
李四 数学 60
李四 英语 90
怎样通过select语句把他变成以下结构:
------------------------------------
姓名 语文成绩 数学成绩 英语成绩
张三 20 30 50
李四 70 60 90
select A.姓名, A.成绩 as 语文成绩,B.成绩 as 数学成绩,C.成绩 as 英语成绩
from student A, student B, student C
where A.姓名 = B.姓名 = C.姓名
and A.科目=语文 and B.科目=数学 and C.科目=英语