一个网站多少钱,岚山建设网站,网站标题的作用,大型网站制作公司飞数简单增删查改
1.创建的商品表中插入一条数据#xff1a;名称为“学生书包”、价格18.91、库存101、描述为空
insert into product(name,price,storage) values(学生书包,18.91,101);
insert into product values (学生书包,18.91,101,null);
2.在图书表中新增一条记录…简单增删查改
1.创建的商品表中插入一条数据名称为“学生书包”、价格18.91、库存101、描述为空
insert into product(name,price,storage) values(学生书包,18.91,101);
insert into product values (学生书包,18.91,101,null);
2.在图书表中新增一条记录Java核心技术、作者“Cay S. Horstman”价格56.43分类为“计算机技术”
insert into book values(Java核心技术,Cay S.Horstman,56.43,计算机技术);
3.删除商品表中价格大于60或者是库存小于200的记录
delete from product where price60 or storage200;
4.修改商品表中 所有库存大于30的商品记录将价格增加50块
update product set priceprice50 where storage30;
5.图书表中 修改“Java核心技术”的图书信息将价格修改为61
update book set price61 where nameJava核心技术;
6.student学生表中字段有姓名name年龄age要求查询姓张并且年龄在18到25岁之间的学生
select * from student where name like 张% and age between 18 and 25;
7.查询article文章表中发表日期create_date在2019年1月1日上午10点30分至2019年11月10日下午4点2分的文章
select * from article where create_date between 2019-01-01 10:30:00 and 2019-11-10 16:02:00;
8.查询article文章表中文章标题title为空或者满足发表日期create_date在2019年1月1日之后
select * from article where title is null or create_date 2019-01-01 00:00:00; 9.查询book图书表中作者author列不为空或者满足条件价格price在50元以上且出版日期publish_date在2019年之后的图书信息
select * from book where author is not null or (price 50 and publish_date2019-01-01 00:00:00);
10.
查询用户user表中同时满足以下两个条件的用户数据
1. ID在1至200或300至500且账号accout列不为空
2. 充值金额amount在1000以上。
select * from user where (id between 1 and 200 or id between 300 and 500) and accout is not null and amount1000;
聚合查询
有一张员工表emp字段姓名name性别sex部门depart工资salary。查询以下数据
1、查询男女员工的平均工资
select sex,avg(salary) from emp group by sex;说明平均值使用聚合函数avg并且按照性别男女分组group by 性别字段
2、查询各部门的总薪水
select depart,sum(salary) from emp group by depart;说明总薪水使用聚合函数sum取薪水字段求和并且按照部门字段分组group by 部门字段
3、查询总薪水排名第二的部门
select depart,sum(salary) from emp group by depart order by sum(salary) desc limit 1,1;说明order by语句先按照总薪水排序之后取第二条数据可以使用分页每一页1条数据第二页就是该结果
4、查询姓名重复的员工信息
select name from emp group by name having count(name)1;说明名字重复说明同一个名字有多条数据可以先按照名字分组分组之后再过滤行数大于1的就表示同一个名字至少有2条记录重复了
5、查询各部门薪水大于10000的男性员工的平均薪水
select depart,avg(salary) from emp where salary10000 and sex男 group by depart;说明这里需要注意题目要求是查询薪水大于10000的男性员工这个是在按部门分组前就过滤在过滤后的结果集中再查询各个部门的平均薪水
有员工表、部门表和薪资表根据查询条件写出对应的sql【同程艺龙2020届校招笔试题】 现在有员工表、部门表和薪资表。 部门表depart的字段有depart_id name 员工表 staff 的字段有 staff_id name age depart_id 薪资表salary 的字段有 salary_idstaff_idsalarymonth。 问题a求每个部门2016-09月份的部门薪水总额 select det.name ,sum(sal.salary) from salary sal
join staff sta on sal.staff_id sta.staff.id
join depart dep on sta.depart_id dep.depart_id
where year (sal.month) 2016
and month (sal.month) 9
group by dep.depart_id 问题b求每个部门的部门人数要求输出部门名称和人数 select dep.name, count(sta.staff_id)from staff stajoin depart dep on dep.depart_id sta.staff_idgroup by sta.depart_id 问题c求公司每个部门的月支出薪资数要求输出月份和本月薪资总数 select dep.name,sal.month,sum(sal.salary)from depart depjoin staff sta on dep.depart_id sta.depart_idjoin salary sal on sta.staff_id sal.staff_idgroup by dep.depart_id ,sal.month;