sql 一个结果集 如何跟另一个集 join 15
select*from(selectattdaydata.EmpNo,EmpName,dtname,EmpTypeName,PartName,sum(OverTime)a...
select * from (
select attdaydata.EmpNo,EmpName,dtname,EmpTypeName,PartName,
sum(OverTime) as skjb,sum(OverTime1+OverTime2+OverTime3) as zsjb,sum(ReqOverTime)as webflow
from attdaydata
join perEmployee on attdaydata.EmpID=perEmployee.EmpID where CONVERT(varchar(12) ,YYMMDD, 112 )
between 20140223 and 20140301 and EmpTypeName='不限36小时'
GROUP BY attdaydata.EmpNo,EmpName,dtname,EmpTypeName,PartName
) as a
--
select * from
(
select workno,sum(sqzss) as sqzss from view_Overtime3 where wovtdte between 20140223 and 20140301 group by workno
)
as b
如何把这两个结果集 连在一起
select * from
(
select * from (
select attdaydata.EmpNo,EmpName,dtname,EmpTypeName,PartName,
sum(OverTime) as skjb,sum(OverTime1+OverTime2+OverTime3) as zsjb,sum(ReqOverTime)as webflow
from attdaydata
join perEmployee on attdaydata.EmpID=perEmployee.EmpID where CONVERT(varchar(12) ,YYMMDD, 112 )
between 20140223 and 20140301 and EmpTypeName='不限36小时'
GROUP BY attdaydata.EmpNo,EmpName,dtname,EmpTypeName,PartName
) as a
join
select * from
(
select workno,sum(sqzss) as sqzss from view_Overtime3 where wovtdte between 20140223 and 20140301
group by workno
)
as b
on a.empno=b.workno
) as c 展开
select attdaydata.EmpNo,EmpName,dtname,EmpTypeName,PartName,
sum(OverTime) as skjb,sum(OverTime1+OverTime2+OverTime3) as zsjb,sum(ReqOverTime)as webflow
from attdaydata
join perEmployee on attdaydata.EmpID=perEmployee.EmpID where CONVERT(varchar(12) ,YYMMDD, 112 )
between 20140223 and 20140301 and EmpTypeName='不限36小时'
GROUP BY attdaydata.EmpNo,EmpName,dtname,EmpTypeName,PartName
) as a
--
select * from
(
select workno,sum(sqzss) as sqzss from view_Overtime3 where wovtdte between 20140223 and 20140301 group by workno
)
as b
如何把这两个结果集 连在一起
select * from
(
select * from (
select attdaydata.EmpNo,EmpName,dtname,EmpTypeName,PartName,
sum(OverTime) as skjb,sum(OverTime1+OverTime2+OverTime3) as zsjb,sum(ReqOverTime)as webflow
from attdaydata
join perEmployee on attdaydata.EmpID=perEmployee.EmpID where CONVERT(varchar(12) ,YYMMDD, 112 )
between 20140223 and 20140301 and EmpTypeName='不限36小时'
GROUP BY attdaydata.EmpNo,EmpName,dtname,EmpTypeName,PartName
) as a
join
select * from
(
select workno,sum(sqzss) as sqzss from view_Overtime3 where wovtdte between 20140223 and 20140301
group by workno
)
as b
on a.empno=b.workno
) as c 展开
3个回答
展开全部
select * from
(
select * from
(
select * from (
select attdaydata.EmpNo,EmpName,dtname,EmpTypeName,PartName,
sum(OverTime) as skjb,sum(OverTime1+OverTime2+OverTime3) as zsjb,sum(ReqOverTime)as webflow
from attdaydata
join perEmployee on attdaydata.EmpID=perEmployee.EmpID where CONVERT(varchar(12) ,YYMMDD, 112 )
between 20140223 and 20140301 and EmpTypeName='不限36小时'
GROUP BY attdaydata.EmpNo,EmpName,dtname,EmpTypeName,PartName
)
) a,
(select * from
(
select workno,sum(sqzss) as sqzss from view_Overtime3 where wovtdte between 20140223 and 20140301
group by workno
)
) b
where a.empno=b.workno
(
select * from
(
select * from (
select attdaydata.EmpNo,EmpName,dtname,EmpTypeName,PartName,
sum(OverTime) as skjb,sum(OverTime1+OverTime2+OverTime3) as zsjb,sum(ReqOverTime)as webflow
from attdaydata
join perEmployee on attdaydata.EmpID=perEmployee.EmpID where CONVERT(varchar(12) ,YYMMDD, 112 )
between 20140223 and 20140301 and EmpTypeName='不限36小时'
GROUP BY attdaydata.EmpNo,EmpName,dtname,EmpTypeName,PartName
)
) a,
(select * from
(
select workno,sum(sqzss) as sqzss from view_Overtime3 where wovtdte between 20140223 and 20140301
group by workno
)
) b
where a.empno=b.workno
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2014-03-05
展开全部
结果集可以用别名的
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
使用union
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询