CREATE VIEW v_OA_GZQJB2View<br>AS<br>SELECT KQStatusID AS GZQJBID, GroupKQStatusID AS GZGKQStatusID,<br> CAST(CAST(DATEPART(year, OA_KQStatus.PerformDate) AS char(4))+ CAST(10 + DATEPART(month,OA_KQStatus.PerformDate) AS char(2)) AS INT) - 10 AS GZID,<br> SQRCode AS UserCode, PerformDate AS QJRQ,<br> (Select sum(isnull(DQJ, 0)) from OA_JBDQJ where JBID=OA_KQStatus.KQStatusID) DJB,<br> SJJB AS DXX, QJHour AS QJKQ,<br> (case when (OA_KQStatus.SQType = '补打卡') then '忘打卡' else OA_KQStatus.QJLB end) AS QJType, <br> (case when (OA_KQStatus.SQType = '补打卡') then 1 else 0 end) TypeID<br><br><br>FROM OA_KQStatus<br>WHERE (IsKnowSP = 1) AND( (SQType = '请假') or ((SQType = '补打卡') and (BDL=1)) )<br><br>UNION<br>SELECT GZQJBID, GZGKQStatusID, GZID, UserCode, QJRQ, DJB, DXX, QJKQ, QJType, 2 as TypeID <br>From OA_GZQJB<br>--------------这是我写视图