我想获取表中某一列的最大值,然后插入到另外一个表中,报错的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.
==》在此上下文中不允许使用子查询。只允许使用标量表达式。
分享到:
相关推荐
1.10 The Structure of This Book . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 CHAPTER 2 The Tennis Club Sample Database . . . . . . . . . . . . . . . . 29 2.1 Introduction . . . . . . . . ....
截至 2011-08-29 官方公布的最新 hibernate 文档,此为英文版,配套中文版下载地址:http://download.csdn.net/source/3557584。 详细信息: 版本:3.6.3.Final,作者:Gavin King, Christian Bauer, Max Rydahl ...
251 ■ Chapter 9: Using Core Data in Advanced Applications.....................................................................283 ■ Index:..............................................................
Table of Contents Introduction....................................................................................................13 Code Examples.........................................................
Normally, only the columns in the WHERE clause are helpful in determining useful indexes, but for a covering index, all columns must be included. If all columns needed for the query are in the index,...
3.8.3. Current Session context management with JTA 3.8.4. JMX deployment 4. Persistent Classes 4.1. A simple POJO example 4.1.1. Implement a no-argument constructor 4.1.2. Provide an identifier ...
What This Book Does Not Cover Conventions Used in This Book Which Version? Resources Available at the Book's Web Site Using Code Examples Safari® Enabled How to Contact Us ...
Security and the User Context . Licensing . Network Protocols . Collation . Multiple Instances . Installing SQL Server . Basic Configuration After Installation . Remote and Unattended ...
Avoid writing queries that are a difficult-to-maintain quagmire of self-joins and nested subqueries Recognize situations that call for window functions, and learn when to use these features Reduce the...
When he's not programming or writing books about programming, he can be found surfing or writing music. "If you ever wanted to learn to use MySQL, write SQL queries, create database elements, then ...
“If you ever wanted to learn to use MySQL, write SQL queries, create database elements, then this is the book to pick up.” (JavaRanch.com) “I was amazed at how much information was packed into ...
Selecting Entities from Subqueries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 Using EXISTS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ...
Topics whose treatment has been expanded include data types and domains, table comparisons, image relations, aggregate operators and summarization, view updating, and subqueries. A special feature of...
What’s Covered in this Book 14 Compatibility 15 2. MapReduce . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 A Weather Dataset...
Window functions do not let you do anything that was impossible to do with earlier functionality, and they have nothing to do with the Microsoft Windows API. Using previously available methods, such ...
Many SQL texts attempt to serve as an encyclopedic reference on SQL syntax -- an approach that is often counterproductive, because that information is readily available in online references published ...
Many SQL texts attempt to serve as an encyclopedic reference on SQL syntax — an approach that is often counterproductive, because that information is readily available in online references published ...
数据库技术与Oracle:sql-06 Subqueries.ppt