一道数据库SQL的设计题

一道数据库SQL的设计题,第1张

1select ssname from s,p,sp where ssno = spsno and sppno = ppno and ppname like '%红色零件%'2select sno, sname, status from s where city='北京'3select sum(spqty) from sp, p where sppno = ppno and ppname like '%P2%'4select sum(pVEIGHT) from sp, p where sppno = ppno and ppname like '%P2%'5update p set color = '**'

1 查询雇员(employee)的姓和名

Select substring(username,1,1) as 姓 from employee

Select substring(username,2,2) as 名 from employee

2 查询雇员的姓名

Select username from employee

3 查询雇员数

Select count() from employee

4 查询雇员的姓名和职务

Select username,,duty from employee

5 查询雇员的工龄

Select year(getdate())-开始工作日期 as 工龄 from employee

任务2:条件查询

1 查询雇员(employee)从事"Sales Representative"职务的有哪些人

Select from employee where duty=’ Sales Representative’

2 查询工龄超过15年的雇员

Select from employee where cast( (year(getdate())-开始工作日期) as int)>=15

3 查询姓以a开头的雇员

Select from employee where username like ‘a%’

4 查询姓的开头字母在m以后的雇员

Select from employee where cast((substring(username,1,1) as varchar)>=’m’

5 认为hire_date是雇员生日,查询巨蟹座的雇员

Select from employee where birthday between ‘6-22 ‘ and ‘7-22’

任务3:联合查询

1 查询雇员和雇员职位

Select aid,bduty from employee, as a,jobs as b

2 查询雇员、雇员职位和雇员所在出版社

Select aid,bduty, bpublishing from employee as a,jobs as b on aid=bid

3 查询雇员、雇员工资、雇员离本职位最高工资的差值

select a ID,ausername,a[雇员工资],b[最高工资]-a[雇员工资] as [差值] from employee a,jobs b where a[职位]=b[职位]

1CREATE TABLE 报酬

职工号 VARCHAR(15),

工程编号 VARCHAR(15),

工资 VARCHAR(15),

PRIMARY KEY(职工号),

REFERENCES (职工号),

REFERENCES (工程编号))

(PS 下外码为“职工号”和“工程编号” 这个要指明是那个表的外键 所以上面我写的是错的

还一个 一个裱中只能有一个主键其中主码为“职工号,工程编号” 所以这句话也是错的)

2SELECT 职工号,count(工资)

FROM 报酬

GROUP BY 职工号

3SELECT FROM 工程 WHERE 预算>100W

4SELECT (工资+工资10%) FROM 报酬 WHERE 工程编号=101

5CREATE VIEW VPS (职工号、姓名、工程名称,工资)

AS SELECT 职工职工号,职工姓名,工程工程名称,报酬工资

WHERE 职工,报酬,工程

6GRANT SELECT ON 报酬 TO 王红

你好的!

select 姓名,部门 from 职工 where 年龄 >40;

select 职工号 from 参加 where 社团编号 = 'XQXZ';

select 活动地点from 社会团体 where 名称 = '合唱团';

select 职工号 from 参加 where 社团编号 <> 'WDXZ';

select a姓名,a性别,a部门 from 职工 a ,参加 b , 社会团体 c where a职工号 = c职工号 

                                            and b社团编号 = c社团编号

                                            and b名称 = '舞蹈社'

这应该是正确答案!

望采纳!

以上就是关于一道数据库SQL的设计题全部的内容,包括:一道数据库SQL的设计题、高分悬赏几道计算机SQL数据库的题!做出来了先支付100分,要是满意的话,在加赏50~、数据库SQL题目求解答!急求!等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/sjk/9346516.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-27
下一篇 2023-04-27

发表评论

登录后才能评论

评论列表(0条)

保存