学习笔记之SQL Programming DB2

本文详细介绍了SQL查询中的一些核心概念和技术,包括如何避免在DECLARECURSOR语句中使用GROUP BY和HAVING子句,理解NULL值的特殊性质,以及在OLAP场景下如何返回排名和行号。同时,阐述了NULL值在比较操作中的行为,以及如何在UNION操作中保持重复记录。此外,还讨论了数据检索错误和SQLCODE的概念,并提供了在INSERT语句中使用SELECT语句的方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

http://publib.boulder.ibm.com/infocenter/iseries/v5r4/index.jsp

  If you intend to update a column or delete a row, you cannot include a GROUP BY or HAVING clause in the SELECT statement within a DECLARE CURSOR statement. These clauses make it a read-only cursor.

  Null values are ordered as the highest value.

  A null value is not the same as zero or all blanks. A null value means unknown. Null values can be used as a condition in the WHERE and HAVING clauses.

  Comparing two columns using a normal equal comparison (COL1 = COL2) will be true if both columns contain an equal non-null value. If both columns are null, the result will be false since null is never equal to any other value, not even another null value. Using the DISTINCT predicate, null values are considered equal. So (COL1 is NOT DISTINCT from COL2) will be true if both columns contain an equal non-null value and also when both columns are the null value.

  Null values are treated as duplicate rows for DISTINCT.

  Online analytical processing (OLAP) specifications are used to return ranking numbers and row numbers for the result rows of a query. You can specify RANK, DENSE_RANK, and ROW_NUMBER.

  The USING clause is equivalent to a join condition where each column from the left table is compared to a column with the same name in the right table.

  ? the use of recursive common table expressions and recursive views.

  If you want to keep duplicates in the result of a UNION, specify UNION ALL instead of just UNION.

  Data retrieval errors/SQLCODE

  You can use a select-statement within an INSERT statement to insert zero, one, or more rows into a table from the result table of the select-statement.

转载于:https://www.cnblogs.com/pegasus923/p/1978400.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值