Subqueries are not allowed in this context. Only scalar expressions are allowed.

简介: 我想获取表中某一列的最大值,然后插入到另外一个表中,报错的Sql如下: insert into AA(AA_ID,AA_YWFSRQ) values(NewID(),( SELECT CONVERT(varchar, DATEADD(day,- 1, CAST(SUBSTRING(MAX(YEB_RQ), 1, 4)

我想获取表中某一列的最大值,然后插入到另外一个表中,报错的Sql如下:

insert into AA(AA_ID,AA_YWFSRQ) 
values
(NewID(),(  SELECT   CONVERT(varchar, DATEADD(day,- 1, CAST(SUBSTRING(MAX(YEB_RQ), 1, 4) 
                                    + SUBSTRING(MAX(YEB_RQ), 5, 2) + SUBSTRING(MAX(YEB_RQ), 7, 2) 
                                     AS datetime)), 112) FROM      YEB ));
修正:

insert into AA(AA_ID,AA_YWFSRQ) 
select
NewID(),(  SELECT   CONVERT(varchar, DATEADD(day,- 1, CAST(SUBSTRING(MAX(YEB_RQ), 1, 4) 
                                    + SUBSTRING(MAX(YEB_RQ), 5, 2) + SUBSTRING(MAX(YEB_RQ), 7, 2) 
                                     AS datetime)), 112) FROM      YEB )
错误提示信息:
        Subqueries are not allowed in this context. Only scalar expressions are allowed.

==》在此上下文中不允许使用子查询。只允许使用标量表达式。

相关文章
|
8月前
|
JavaScript 程序员 Swift
The compiler is unable to type-check this expression in reasonable time; try breaking up the express
The compiler is unable to type-check this expression in reasonable time; try breaking up the express
88 0
|
8月前
|
小程序 JavaScript
Avoid mutating a prop directly since the value will be overwritten whenever the parent comp
Avoid mutating a prop directly since the value will be overwritten whenever the parent comp
解决Mapped Statements collection already contains value for experiment4.UserMapper.listUser错误~
解决Mapped Statements collection already contains value for experiment4.UserMapper.listUser错误~
108 0
params argument given to the optimizer should be an iterable
params argument given to the optimizer should be an iterable
196 0
params argument given to the optimizer should be an iterable
|
C语言
error: implicit declaration of function ‘VerifyFixClassname‘ is invalid in C99 [-Werror,-Wimplicit-f
error: implicit declaration of function ‘VerifyFixClassname‘ is invalid in C99 [-Werror,-Wimplicit-f
159 0
|
人工智能 C++
Longest Valid Parentheses
Given a string containing just the characters '(' and ')', find the length of the longest valid (well-formed) parentheses substring.
782 0
|
分布式计算 Spark
Spark - ReturnStatementInClosureException: Return statements aren‘t allowed in Spark closures
Spark 使用 RDD 调用 Filter 函数时,dirver 端卡住,报错 ReturnStatementInClosureException: Return statements aren't allowed in Spark closures,即闭包内无法使用 return 函数。
352 0
Spark - ReturnStatementInClosureException: Return statements aren‘t allowed in Spark closures
成功解决ValueError: numpy.ufunc size changed, may indicate binary incompatibility. Expected 216 from C h
成功解决ValueError: numpy.ufunc size changed, may indicate binary incompatibility. Expected 216 from C h
成功解决ValueError: numpy.ufunc size changed, may indicate binary incompatibility. Expected 216 from C h
成功解决TypeError: Value passed to parameter 'paddings' has DataType float32 not in list of allowed valu
成功解决TypeError: Value passed to parameter 'paddings' has DataType float32 not in list of allowed valu