select * from (select t1.[id] as t1_id,t1.[requestId] as t1_requestId,t1.[htqsrq] as t1_htqsrq,t1.[htjzrq] as t1_htjzrq,t1.[htbh] as t1_htbh,t1.[gf] as t1_gf,t1.[xf] as t1_xf,t1.[rq] as t1_rq,t1.[fkfs] as t1_fkfs,t1.[formmodeid] as t1_formmodeid,t1.[modedatacreater] as t1_modedatacreater,t1.[modedatacreatertype] as t1_modedatacreatertype,t1.[modedatacreatedate] as t1_modedatacreatedate,t1.[modedatacreatetime] as t1_modedatacreatetime,t1.[modedatamodifier] as t1_modedatamodifier,t1.[modedatamodifydatetime] as t1_modedatamodifydatetime,t1.[form_biz_id] as t1_form_biz_id,t1.[MODEUUID] as t1_MODEUUID,t1.[htfj] as t1_htfj,t1.[zje] as t1_zje,t1.[ds] as t1_ds,t1.[zjedx] as t1_zjedx,t1.[cspp] as t1_cspp,t1.[yfk] as t1_yfk,t1.[gxid] as t1_gxid,t1.[bz] as t1_bz,t1.[gfqymc] as t1_gfqymc,t1.[gfjc] as t1_gfjc,t1.[bh] as t1_bh,t1.[jylx] as t1_jylx,t1.[cght] as t1_cght,t1.[yf] as t1_yf,t1.[yfk1] as t1_yfk1,t1.[yf11] as t1_yf11,t1.[nf] as t1_nf,t1.[rksj] as t1_rksj,t1.[cclx] as t1_cclx,t1.[cgbt] as t1_cgbt,t1.[yfk2] as t1_yfk2,t1.[sywf] as t1_sywf,t1.[yfbl] as t1_yfbl,t1.[fhbl] as t1_fhbl,t1.[yfh] as t1_yfh,t1.[sykf] as t1_sykf,t1.[hzsdlqys] as t1_hzsdlqys,t1.[sys_workflowid] as t1_sys_workflowid,t1.[cgqzyz] as t1_cgqzyz,t1.[htwjpdf] as t1_htwjpdf,t1.[cghtlc] as t1_cghtlc,t1.[htzt] as t1_htzt,t1.[qzfs] as t1_qzfs,t1.[htwjtp] as t1_htwjtp,t1.[cgqzlc] as t1_cgqzlc,t1.[sjfk] as t1_sjfk,t1.[ydkds] as t1_ydkds,t1.[chpt] as t1_chpt,t1.[lxdhchr] as t1_lxdhchr,t1.[gxsjkx] as t1_gxsjkx,t1.[hkzt] as t1_hkzt,t1.[lcfkd] as t1_lcfkd,t1.[fkzlcid] as t1_fkzlcid,t1.[mode_top_4] as t1_mode_top_4,t1.[cgdj] as t1_cgdj,t1.[mode_top_22] as t1_mode_top_22,t2.[id] as t2_id,t2.[mainid] as t2_mainid,t2.[sld] as t2_sld,t2.[ppcj] as t2_ppcj,t2.[hsdj] as t2_hsdj,t2.[bz] as t2_bz,t2.[je] as t2_je,t2.[xhggyt] as t2_xhggyt,t2.[mxgxid] as t2_mxgxid,t2.[dqkckc] as t2_dqkckc,t2.[rkhkc] as t2_rkhkc,t2.[yf] as t2_yf,t2.[yldjbhyf] as t2_yldjbhyf,SELECT year(rksj) as 年 FROM uf_gfht as cus_年年 from uf_gfht t1 INNER join uf_gfht_dt1 t2 on t1.id = t2.mainid) tmp1 where t1 错在哪里
时间: 2023-06-18 09:05:18 浏览: 123
这段 SQL 语句有语法错误,其中的 `SELECT` 语句需要在外层再嵌套一层括号以便正确引用别名。正确的语句应该是:
```
SELECT tmp1.*, tmp2.年
FROM
(SELECT t1.[id] as t1_id, t1.[requestId] as t1_requestId, t1.[htqsrq] as t1_htqsrq, t1.[htjzrq] as t1_htjzrq, t1.[htbh] as t1_htbh, t1.[gf] as t1_gf, t1.[xf] as t1_xf, t1.[rq] as t1_rq, t1.[fkfs] as t1_fkfs, t1.[formmodeid] as t1_formmodeid, t1.[modedatacreater] as t1_modedatacreater, t1.[modedatacreatertype] as t1_modedatacreatertype, t1.[modedatacreatedate] as t1_modedatacreatedate, t1.[modedatacreatetime] as t1_modedatacreatetime, t1.[modedatamodifier] as t1_modedatamodifier, t1.[modedatamodifydatetime] as t1_modedatamodifydatetime, t1.[form_biz_id] as t1_form_biz_id, t1.[MODEUUID] as t1_MODEUUID, t1.[htfj] as t1_htfj, t1.[zje] as t1_zje, t1.[ds] as t1_ds, t1.[zjedx] as t1_zjedx, t1.[cspp] as t1_cspp, t1.[yfk] as t1_yfk, t1.[gxid] as t1_gxid, t1.[bz] as t1_bz, t1.[gfqymc] as t1_gfqymc, t1.[gfjc] as t1_gfjc, t1.[bh] as t1_bh, t1.[jylx] as t1_jylx, t1.[cght] as t1_cght, t1.[yf] as t1_yf, t1.[yfk1] as t1_yfk1, t1.[yf11] as t1_yf11, t1.[nf] as t1_nf, t1.[rksj] as t1_rksj, t1.[cclx] as t1_cclx, t1.[cgbt] as t1_cgbt, t1.[yfk2] as t1_yfk2, t1.[sywf] as t1_sywf, t1.[yfbl] as t1_yfbl, t1.[fhbl] as t1_fhbl, t1.[yfh] as t1_yfh, t1.[sykf] as t1_sykf, t1.[hzsdlqys] as t1_hzsdlqys, t1.[sys_workflowid] as t1_sys_workflowid, t1.[cgqzyz] as t1_cgqzyz, t1.[htwjpdf] as t1_htwjpdf, t1.[cghtlc] as t1_cghtlc, t1.[htzt] as t1_htzt, t1.[qzfs] as t1_qzfs, t1.[htwjtp] as t1_htwjtp, t1.[cgqzlc] as t1_cgqzlc, t1.[sjfk] as t1_sjfk, t1.[ydkds] as t1_ydkds, t1.[chpt] as t1_chpt, t1.[lxdhchr] as t1_lxdhchr, t1.[gxsjkx] as t1_gxsjkx, t1.[hkzt] as t1_hkzt, t1.[lcfkd] as t1_lcfkd, t1.[fkzlcid] as t1_fkzlcid, t1.[mode_top_4] as t1_mode_top_4, t1.[cgdj] as t1_cgdj, t1.[mode_top_22] as t1_mode_top_22, t2.[id] as t2_id, t2.[mainid] as t2_mainid, t2.[sld] as t2_sld, t2.[ppcj] as t2_ppcj, t2.[hsdj] as t2_hsdj, t2.[bz] as t2_bz, t2.[je] as t2_je, t2.[xhggyt] as t2_xhggyt, t2.[mxgxid] as t2_mxgxid, t2.[dqkckc] as t2_dqkckc, t2.[rkhkc] as t2_rkhkc, t2.[yf] as t2_yf, t2.[yldjbhyf] as t2_yldjbhyf
FROM uf_gfht t1
INNER JOIN uf_gfht_dt1 t2 ON t1.id = t2.mainid) tmp1
INNER JOIN
(SELECT year(rksj) as 年 FROM uf_gfht) tmp2
ON tmp1.t1_rksj = tmp2.年
```
阅读全文