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JL_MAX_TAG MAX_RJL_TAG
,LDL_MIN_TAG MIN_LHL_TAG
,LDL_MAX_TAG MAX_LHL_TAG
,JZXG_MIN_TAG MIN_JZ_GD_TAG
,JZXG_MAX_TAG MAX_JZ_GD_TAG
,1 HT_LX
,1 KFLY_BZ
,‘‘ WKFLY_YY
,0 SF_SH
,-1 XZ_ZT
,‘‘ QY_SS_LX
,-1 LSXZ_ZT
,1 HAVE_JZD
,B.SQYD_DW SRR
,‘‘ CX_YY
,‘‘ IS_STOP
,0 ZJGG_MJ
,XM_ZT GDXM_GZZT,
--YD 交地、动工、竣工 BG_JD_SJ,BG_DG_SJ,BG_JG_SJ
YDDG_SJ BG_DG_SJ,
YDJG_SJ BG_JG_SJ
,YDJD_SJ BG_JD_SJ
FROM T_GD_YWBH A INNER JOIN
T_GD_XMXX B ON A.GD_GUID=B.GD_GUID
LEFT JOIN T_KC_KCDJ_CG C ON B.XM_GUID=C.XM_GUID
LEFT JOIN T_KC_ZDXX D ON C.CHCG_GUID=D.CHCG_GUID
LEFT JOIN T_GD_XMXX_KZ_GYMJ E ON B.XM_GUID=E.XM_GUID
LEFT JOIN T_KF_KFLY_YD F ON B.XM_GUID=F.XM_GUID
LEFT JOIN T_KF_TZQD_YD G ON G.KFLY_GUID=F.KFLY_GUID
LEFT JOIN T_KF_CRTJ_YD H ON H.KFLY_GUID=F.KFLY_GUID
LEFT JOIN T_HBJDS I ON B.XM_GUID=I.XM_GUID
LEFT JOIN T_HT_CRHT J ON B.XM_GUID=J.XM_GUID
LEFT JOIN T_SP_SPXX K ON B.XM_GUID=K.XM_GUID


WHERE B.MARK=0;

视图中添加主键的方法

标签:

原文地址:http://www.cnblogs.com/lihfeiblogs/p/5620036.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!