每日小记(16 .9.7)

来源:互联网 发布:手机如何查看淘宝粉丝 编辑:程序博客网 时间:2024/06/05 07:27

关于数据库:

数据库插入语句:

insert into table (col1,col2) values (v1,v2);

 去数据库前十条数据 

oracle: select * from table where rownum<=10;

mysql : select * from table limit 10;

sql server : select top 10 * from table;

关于数据库 某一列要计算总数:

求学生各科成绩之和:

select t.name,sum(e.score)
from student t 
join exam e 
on t.no=e.no
group by t.name

关于区分成绩等级:

select t.name ,e.subject, 
case 
when e.score>=90 and e.score<100 then 'good'
when e.score>=80 and e.score<90 then 'not good'
else 'false'
end
from exam e
join student t
on e.no=t.no

删除表中所有数据;

truncate exam;

0 0
原创粉丝点击