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错在哪里
时间: 2023-06-18 13:05:16 浏览: 142
这条 SQL 语句有语法和逻辑错误,需要进行修改:
1. 子查询中 `SELECT year(rksj) as 年` 语句没有给出别名,需要修改为 `SELECT year(rksj) as 年份` 等合适的别名。
2. 子查询中的两个表需要指定别名,例如 `FROM uf_gfht as t1 INNER JOIN uf_gfht_dt1 as t2 ON t1.id = t2.mainid`。
3. 子查询中需要将结果集与别名绑定,例如 `SELECT tmp1.年份 FROM (...) tmp1`。
修改后的 SQL 语句如下:
```
SELECT tmp1.t1_id, tmp1.t1_requestId, tmp1.t1_htqsrq, tmp1.t1_htjzrq, tmp1.t1_htbh, tmp1.t1_gf, tmp1.t1_xf, tmp1.t1_rq, tmp1.t1_fkfs, tmp1.t1_formmodeid, tmp1.t1_modedatacreater, tmp1.t1_modedatacreatertype, tmp1.t1_modedatacreatedate, tmp1.t1_modedatacreatetime, tmp1.t1_modedatamodifier, tmp1.t1_modedatamodifydatetime, tmp1.t1_form_biz_id, tmp1.t1_MODEUUID, tmp1.t1_htfj, tmp1.t1_zje, tmp1.t1_ds, tmp1.t1_zjedx, tmp1.t1_cspp, tmp1.t1_yfk, tmp1.t1_gxid, tmp1.t1_bz, tmp1.t1_gfqymc, tmp1.t1_gfjc, tmp1.t1_bh, tmp1.t1_jylx, tmp1.t1_cght, tmp1.t1_yf, tmp1.t1_yfk1, tmp1.t1_yf11, tmp1.t1_nf, tmp1.t1_rksj, tmp1.t1_cclx, tmp1.t1_cgbt, tmp1.t1_yfk2, tmp1.t1_sywf, tmp1.t1_yfbl, tmp1.t1_fhbl, tmp1.t1_yfh, tmp1.t1_sykf, tmp1.t1_hzsdlqys, tmp1.t1_sys_workflowid, tmp1.t1_cgqzyz, tmp1.t1_htwjpdf, tmp1.t1_cghtlc, tmp1.t1_htzt, tmp1.t1_qzfs, tmp1.t1_htwjtp, tmp1.t1_cgqzlc, tmp1.t1_sjfk, tmp1.t1_ydkds, tmp1.t1_chpt, tmp1.t1_lxdhchr, tmp1.t1_gxsjkx, tmp1.t1_hkzt, tmp1.t1_lcfkd, tmp1.t1_fkzlcid, tmp1.t1_mode_top_4, tmp1.t1_cgdj, tmp1.t1_mode_top_22, tmp1.t2_id, tmp1.t2_mainid, tmp1.t2_sld, tmp1.t2_ppcj, tmp1.t2_hsdj, tmp1.t2_bz, tmp1.t2_je, tmp1.t2_xhggyt, tmp1.t2_mxgxid, tmp1.t2_dqkckc, tmp1.t2_rkhkc, tmp1.t2_yf, tmp1.t2_yldjbhyf, tmp1.年份
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(t1.rksj) as 年份 FROM uf_gfht as t1 INNER JOIN uf_gfht_dt1 as t2 ON t1.id = t2.mainid) AS tmp1;
```
阅读全文