这个数据库题目用SQL2000 SQL语言怎么写? 数据库问题,请问这个sql语句怎么写

作者&投稿:拔软 (若有异议请与网页底部的电邮联系)
--(1)查询所有女性职工的基本信息
select * from 职工 where 性别='女'

--(2)查询职工号为“SH2009-03”职工姓名、所在岗位以及工资
select 职工名,所在岗位,工资
from 职工
inner join 工作
on 工作.职工号=职工.职工号
where 职工.职工号='SH2009-03'

--(3)将年龄超过50岁职工的工资增加200元
update 工作 set 工资=工资+200
from 工作
inner join 职工
on 工作.职工号=职工.职工号
where 年龄>50

--(4)删除所有在“XX日产公司”工作的职工的工作记录
--这句删除的是职工和工作表的信息(因为你描述的不是很清楚,如果不想删除哪个,
--你就在Delete后面去掉就可以了)
delete 工作.*,职工.* from 公司
inner join 工作 on 工作.公司号=公司.公司号
inner join 职工 on 职工.职工号=工作.职工号
where 公司名 like '%日产公司'

--(5)创建一个简单的视图,查询公司号为“TP2004521”,工资介于3000—5000的职工信息
create view TestView
as
select 职工.*,公司.*,工作.工资
from 公司
inner join 工作 on 工作.公司号=公司.公司号
inner join 职工 on 职工.职工号=工作.职工号
where 公司.公司号='TP2004521' and 工作.工资 between 3000 and 5000

--(6)把插入权限赋给职工名为“张三”
if exists(select * from sysobjects where name='trig_Test')
drop trigger trig_Test
go
create trigger trig_Test
on 职工
for insert
as
if(select 职工名 from inserted)!='张三'
begin
print '拒绝插入'
rollback transaction
end
go

(1)select a.*,b.工资,b.公司号,c.公司名,c.地址 from 职工 a,工作 b,公司 c where a.职工号=b.职工号 and b.公司号=c.公司号 and 性别='女'
(2)select a.职工名,a.所在岗位,b.工资 from 职工 a,工作 b where a.职工号='SH2009-03'
(3)update 工作 set 工作.工资=工作.工资+200 where 职工.职工号=工作.职工号 and 职工.年龄>50
(4)描述不清
(5)create view viewname
as
select a.* from 职工 a,工作 b where a.职工号=b.职工号 and b.公司号='TP2004521' and b.工资 between 3000 and 5000
go
(6)...

这几道题用数据库的SQL语言怎么实现?~

第一个:
select MAX(职工号)
from 职工
where 职工. 部门号 in (select 部门号 from 部门)


第二个:
create proc procStaff
@staffID nvarchar(30) --@staffID 表示职工号
as
select 月工资, avg(select 月工资 from 职工 where 职工号 = @staffID
and 部门 in (select 部门号 from 部门))
from 职工
where 职工号 = @staffID

第三个:
select productID , productName , Max(clickNum)
from productInfo
where productInfo.parentID in(select chassID from className group by classID)
group by productName
order by Max(clickNum) desc

本程序已经在Microsoft SQL Server Management Studio 18 里实现。

如果有什么疑问(或不同意见)可以提出来o(* ̄▽ ̄*)o
源代码:
CREATE VIEW VIEW1
AS SELECT 所在系,课程号,AVG(成绩) 平均成绩
FROM Student, SC
WHERE Student.学号 = SC.学号
GROUP BY 所在系,课程号
HAVING AVG(成绩) > 80;