日期:2014-05-17 浏览次数:20514 次
create view myview
as
select a.职员姓名,sum(b.工资) as 工资总额,avg(b.工资) as 平均工资
from 职员表 a,工资表 b,部门表 c
where a.职员ID=b.职员ID and (部门= '研发部 ' and a.部门ID=c.部门ID)
and (月份> = '2012-1-1 ' and 月份 <= '2012-7-31 ')
and b.工资=(select max(工资) from 工资表)
CREATE VIEW test
AS
SELECT TOP 1 职员姓名,SUM(工资)总额,AVG (工资)平均
FROM 职员表 a INNER JOIN 部门表 b ON a.部门ID=b.部门ID
INNER JOIN 工资表 c ON a.职员ID =c.职员ID
WHERE b.部门='研发部' AND c.月份 BETWEEN '1' AND '7'--猜测你的数据而已
GROUP BY 职员姓名
ORDER BY 工资 desc
CREATE VIEW test
AS
SELECT TOP 1 职员姓名,SUM(工资)总额,AVG (工资)平均
FROM 职员表 a INNER JOIN 部门表 b ON a.部门ID=b.部门ID
INNER JOIN 工资表 c ON a.职员ID =c.职员ID
WHERE b.部门='研发部' AND c.月份 BETWEEN '1' AND '7'--猜测你的数据而已
GROUP BY 职员姓名
ORDER BY 工资