ORA-01791: not a SELECTed expression
Student表有3个字段:id,name,age
看这两个SQL语句
(1)select name from student order by id;
(2)select distinct(name) from student order by id;
执行结果你可能会说:
第1句返回以id排序的所有name字段
第2句返回以id排序的所有不重复的name字段.
但是执行结果不是这样的,第2句会报ORA-01791: not a SELECTed expression
原因:
一般来说,order by 的排序字段是可以不出现在select查询字段列表中的,但当查询中使用了DISTINCT或者GROUP BY子句时,order by中的排序字段就必须出现在select列表中,否则就会报上述错误.
第2句应改成 select distinct(name),id from student order by id
或者 select distinct(name) from student order by name
ORA-01791: not a SELECTed expression的更多相关文章
- ORA-01791: not a SELECTed expression 一种是不 bug 的 bug!
[ora11@lixora ~]$ !sql sqlplus / as sysdba SQL*Plus: Release 11.2.0.1.0 Production on Wed Aug 27 09: ...
- [20170728]oracle保留字.txt
[20170728]oracle保留字.txt --//oracle有许多保留字,我印象最深的就是使用rman备份表空间test,test就是rman里面的保留字.--//还有rman也是rman里面 ...
- Visual Studio 2010 Shortcut
General Shortcut Description Ctrl-X or Shift-Delete Cuts the currently selected item to the clipboar ...
- 零元学Expression Blend 4 - Chapter 27 PathlistBox被Selected时的蓝底蓝框问题
原文:零元学Expression Blend 4 - Chapter 27 PathlistBox被Selected时的蓝底蓝框问题 最近收到网友Cloud的来信,询问我有关放进PathlistBox ...
- ORA 各种oraclesql错误
ORA-00001: 违反唯一约束条件 (.) ORA-00017: 请求会话以设置跟踪事件 ORA-00018: 超出最大会话数 ORA-00019: 超出最大会话许可数 ORA-00020: 超出 ...
- (转载)SQL Reporting Services (Expression Examples)
https://msdn.microsoft.com/en-us/library/ms157328(v=SQL.100).aspx Expressions are used frequently in ...
- Expression<Func<T,TResult>>和Func<T,TResult>
1.Expression<Func<T,TResult>>是表达式 //使用LambdaExpression构建表达式树 Expression<Func<int, ...
- Microsoft Word Regular Expression
Microsoft Word Regular Expression Word裏的正則表達式-不一樣的符號. 一.Normal Find and Replace 二.Search by using wi ...
- Oracle Ora 错误解决方案合集
注:本文来源于 < Oracle学习笔记 --- Oracle ORA错误解决方案 > ORA-00001: 违反唯一约束条件 (.)错误说明:当在唯一索引所对应的列上键入重复值时,会触发 ...
随机推荐
- Lucky Array CodeForces - 121E (线段树,好题)
题目链接 题目大意: 定义只含数字$4,7$的数字为幸运数, 给定序列, 区间加正数, 区间询问多少个幸运数 题解: 对于每一个数, 求出它和第一个比它大的幸运数之差, 则问题转化为区间加,查询$0$ ...
- hdu1358 kmp的next数组
For each prefix of a given string S with N characters (each character has an ASCII code between 97 a ...
- UVA-10689 Yet another Number Sequence (矩阵二分幂模板)
题目大意:已知递推公式和边缘值,求某项的最后m(0<m<5)位数字. 题目分析:矩阵二分幂的模板题. 代码如下: # include<iostream> # include&l ...
- Leetcode 784
//这代码可真丑陋,但我学到了两点1:char和string可以无缝互相转换2:char可以直接加减数字进行转换string不行 class Solution { public: vector< ...
- dp入门求最大公共子序列
#include "bits/stdc++.h" using namespace std; ],b[]; ][]; int main() { cin >> a > ...
- spting Boot 创建一个springBoot项目
spting Boot 创建一个springBoot项目 1)学习springBoot使用软件:IDEA软件(前面的文章有安装idea的过程). 也可以使用另一种方法在https://start.sp ...
- utime修改文件的存取,修改时间
#include <sys/types.h> #include <utime.h> int utime(const char *filename, const struct u ...
- EL表达式、 jstl标签
https://www.cnblogs.com/zhaotiancheng/p/6391894.html https://blog.csdn.net/zdwzzu2006/article/detail ...
- IIS6.0发布后对路径“D:\xxx\xxxx\web.config”的访问被拒绝问题的解决方法
原来我本机发布后还是可以直接通过浏览器访问,这几天不知道怎么就不行,终于在网上找到解决方法 IIS发布后访问xxx/xxx/web.config路径被拒绝的问题截图如下: 解决方法: 1.在本地或服务 ...
- HDU 1936 区间贪心
/* *区间贪心.前几天刚做了POJ 1328 ...思路完全相同... *最多有100个表情,100行文字.遍历寻找每个表情的所在区间.时间复杂度大约在10^5 ~ 10^6 可以接受. *然后对每 ...