简体   繁体   English

SQL-EXISTS不引入子查询

[英]SQL - subquery is not introduced with EXISTS

I am trying to update all creditCounts except for the first (lowest) account number, however I keep receiving this error: 我正在尝试更新除第一个(最低)帐号以外的所有creditCounts ,但是我一直收到此错误:

Msg 116, Level 16, State 1, Line 8 消息116,第16层,状态1,第8行
Only one expression can be specified in the select list when the subquery is not introduced with EXISTS. 如果未使用EXISTS引入子查询,则只能在选择列表中指定一个表达式。

Here is the query: 这是查询:

update Recog
set livesCount = 0
where RECID in (select 
                    r.empNumber, r.acctNbr, r.creditCount, r.groupAcctNumber, r.groupType
                from 
                    Recog r
                where 
                    creditCount > 0 
                    and policyNbr in 
                        (
                            (Select acctNbr from Recog)
                            except 
                            (Select MIN(acctNbr) 
                             from Recog 
                             Group By groupAcctNumber, groupType)
                            )
                        )

How do I fix it? 我如何解决它?

As the error states, you are SELECTing multiple columns in the subquery and it only makes sense to select one... 由于错误状态,您正在子查询中选择多个列,仅选择一个是有意义的...

update Recog
    set livesCount = 0
    where RECID in (
    select r.RECID
    from Recog r
          where creditCount > 0 and
          policyNbr in ((Select acctNbr from Recog)
          except (Select MIN(acctNbr) from Recog Group By groupAcctNumber,groupType)))

To drive it home, imagine what your statement would look like if you substituted column data in place of your subselect... 为了将它带回家,请想象一下,如果用列数据代替子选择项,语句将是什么样子...

update Recog
    set livesCount = 0
    where RECID in (1, 'Account 123', 12, 'Group 123', 'Type X') -- Makes no sense

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 存在的存储过程不引入子查询 - Subquery is not introduced with exists, stored procedure 如何解决 EXISTS 中没有引入子查询的错误? - How resolve a error that a subquery is not introduced with EXISTS? 如果未使用EXISTS引入子查询,则只能在选择列表中指定一个表达式。 -SQL Server - Only one expression can be specified in the select list when the subquery is not introduced with EXISTS. - SQL Server SQL-如果未使用EXISTS引入子查询,则只能在选择列表中指定一个表达式 - SQL - Only one expression can be specified in the select list when the subquery is not introduced with EXISTS SQL Server:当EXISTS未引入子查询时,只能在选择列表中指定一个表达式 - SQL Server : Only one expression can be specified in the select list when the subquery is not introduced with EXISTS 未使用EXISTS引入子查询时,只能在选择列表中指定一个表达式-sql中的错误 - Only one expression can be specified in the select list when the subquery is not introduced with EXISTS — error in sql ERROR SQL Server ONLY 一个表达式可以在选择列表中指定当子查询没有引入时 - ERROR SQL Server ONLY one expression can be specified in the select list when the subquery is not introduced with exists SQL Server错误:当未使用EXISTS引入子查询时,只能在选择列表中指定一个表达式 - SQL Server error :only one expression can be specified in the select list when the subquery is not introduced with EXISTS SQL Server数据库错误:如果未使用EXISTS引入子查询,则只能在选择列表中指定一个表达式 - SQL Server Database Error: Only one expression can be specified in the select list when the subquery is not introduced with EXISTS SQL : 当子查询没有用 EXISTS 引入时,选择列表中只能指定一个表达式 - SQL : Only one expression can be specified in the select list when the subquery is not introduced with EXISTS
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM