SGGL_HBAZ/DataBase/版本日志/SGGLDB_V2025-03-17-001-gaof...

33 lines
2.2 KiB
Transact-SQL

ALTER VIEW [dbo].[View_QuantityManagement_DayInput]
AS
/********¹¤³ÌÁ¿ÈÕ³£Í³¼Æ±í********/
select distinct C.BaseId,C.ProjectId,case when a.DrawingNo is not null then a.WorkSection else b.WorkSection end as WorkSection,case when a.DrawingNo is not null then a.DrawingNo else b.ChangeNo end as DrawingNo,
case when a.DrawingName is not null then a.DrawingName else b.ChangeName end as DrawingName,ba.State,
case when a.DrawingNo is not null then ca.ProfessionalName else cb.ProfessionalName end as Major,ba.DrawingId
Part,ProjectContent,Unit,Amount,t.TeamGroupName as WorkTeam,C.WorkTeam as WorkTeamId
from QuantityManagement_DayInput C
left join QuantityManagement_Base ba on ba.BaseId=C.BaseId
left join QuantityManagement_Drawing a on a.DrawingId=ba.DrawingId
left join Base_CNProfessional ca on ca.CNProfessionalId=a.Major
left join QuantityManagement_Change b on b.ChangeId=ba.DrawingId
left join Base_CNProfessional cb on cb.CNProfessionalId=b.Major
left join ProjectData_TeamGroup t on t.TeamGroupId=C.WorkTeam
union
select BaseId,C.ProjectId,case when a.DrawingNo is not null then a.WorkSection else b.WorkSection end as WorkSection,case when a.DrawingNo is not null then a.DrawingNo else b.ChangeNo end as DrawingNo,
case when a.DrawingName is not null then a.DrawingName else b.ChangeName end as DrawingName,C.State,
case when a.DrawingNo is not null then ca.ProfessionalName else cb.ProfessionalName end as Major,C.DrawingId
Part,ProjectContent,Unit,Amount,t.TeamGroupName as WorkTeam,C.WorkTeam as WorkTeamId
from QuantityManagement_Base C
left join QuantityManagement_Drawing a on a.DrawingId=C.DrawingId
left join Base_CNProfessional ca on ca.CNProfessionalId=a.Major
left join QuantityManagement_Change b on b.ChangeId=C.DrawingId
left join Base_CNProfessional cb on cb.CNProfessionalId=b.Major
left join ProjectData_TeamGroup t on t.TeamGroupId=C.WorkTeam
GO