sql查询

1. where子句中是不能用聚集函数作为条件表达式。

select sno from sc
where avg(grade) > 90
group by sno;

改为

select sno from sc 
group by sno
having avg(grade) >90;

 2.

写法顺序:select--from--where--group by--having--order by 
执行顺序:from--where--group by--having--select--order by
就是select要放后面,如果有order by,则order by放最后,因为order by 是对结果进行排序

 

 3.

 

 4.删除主键操作

表中删除主键为:
alert table table_test drop primary key;
表中增加主键为:
alert table table_test add primary key(id);
 
5.建立视图
 
  建立物联网系的学生的视图(IOT_S)
 
create view IOT_S(sno,sname,sex,prov)
as 
select sno,sname,sex,prov 
from S
where Sdept = "物联网系";

  

posted @ 2020-04-07 12:30  天凉好个秋秋  阅读(132)  评论(0编辑  收藏  举报