当前位置: 代码迷 >> Sql Server >> SQL语句union all语句的有关问题
  详细解决方案

SQL语句union all语句的有关问题

热度:28   发布时间:2016-04-27 12:08:18.0
SQL语句union all语句的问题
select deptcode as deptcode, subjcode as subjcode, nfundingneeds as nfundingneeds, localdebitamount as localdebitamount, flossadj as flossadj, flossvalue as flossvalue, monthcashbgt as monthcashbgt, monthexe as monthexe, monthadj as monthadj, monthbgt as monthbgt from
(select * from TEMQ_GXZYKMY union all select * from TEMQ_GXZYKME union all select * from TEMQ_GXZYKMS union all select * from TEMQ_GXZYKMSi union all select * from TEMQ_GXZYKMW)
as un

大侠们,帮忙看看这段SQL语句里面有什么问题?

------解决方案--------------------
SQL code
SELECT deptcode         AS deptcode,       subjcode         AS subjcode,       nfundingneeds    AS nfundingneeds,       localdebitamount AS localdebitamount,       flossadj         AS flossadj,       flossvalue       AS flossvalue,       monthcashbgt     AS monthcashbgt,       monthexe         AS monthexe,       monthadj         AS monthadj,       monthbgt         AS monthbgtFROM   (SELECT *        FROM   TEMQ_GXZYKMY        UNION ALL        SELECT *        FROM   TEMQ_GXZYKME        UNION ALL        SELECT *        FROM   TEMQ_GXZYKMS        UNION ALL        SELECT *        FROM   TEMQ_GXZYKMSi        UNION ALL        SELECT *        FROM   TEMQ_GXZYKMW ) AS un 确保 TEMQ_XXX 这些表中的 列列类型一直,如果不一直转换成一直的。而且 每个 * 代表的字段数量都一样
------解决方案--------------------
没有问题,你执行报什么错?
------解决方案--------------------
探讨

DB2 SQL error: SQLCODE: -206,
SQLSTATE: 42703,
SQLERRMC: NFUNDINGNEEDS
SQL---就是刚才语句了

------解决方案--------------------
检查下表里面是否有NFUNDINGNEEDS这个字段,或则你是不是拼写错误了