The ORDER BY clause is invalid in views, inline functions, derived tables, subqueries, and common table expressions, unless TOP or FOR XML is also specified.
https://stackoverflow.com/questions/30045871/sorting-the-view-based-on-frequency-in-sql-server
Just like in sub queries, you can't use ORDER BY
in a view definition in sql server unless you also use TOP
.
The reason for this is that Views are acted upon as if they where tables, and tables in sql server (in fact, in any relational database) are considered as not ordered sets.
Just like there is no meaning to the order of records stored in a table,
there is also no meaning to the order of records fetched by a view.
You can use a dirty hack and write SELECT TOP 100 PERCENT ...
and then use ORDER BY
, but I doubt if it has any meaning at all.
Having said all that, you can of course use ORDER BY
in any query that selects from a view.
The ORDER BY clause is invalid in views, inline functions, derived tables, subqueries, and common table expressions, unless TOP or FOR XML is also specified.的更多相关文章
- T-SQL Part IV: ORDER BY
ORDER BY 返回一个Cursor,并不返回结果集.而试图将Cursor作为输入将产生了错误. 所以,下列的SQL语句将产生错误: SELECT VerID, IsComplete VerID, ...
- [Err] 1055 - Expression #1 of ORDER BY clause is not in GROUP BY clause 的问题 MySQL
问题:[Err] 1055 - Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregate ...
- 1055 - Expression #1 of ORDER BY clause is not in GROUP BY clause and contai
之前一直使用的mysql5,突然换成8之后,有许多地方不一样,今天就碰到一个. 在使用sql语句创建表时,报错: 1055 - Expression #1 of ORDER BY clause is ...
- MYSQL---Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column '
--数据库中插入数据或执行sql语句时一直报下面这个错误: Expression # of ORDER BY clause is not in GROUP BY clause and contains ...
- mysql(5.7以上)查询报错:ORDER BY clause is not in GROUP BY..this is incompatible with sql_mode=only_full_group_by
执行mysql命令查询时: select * from table_name错误信息如: [Err] 1055 - Expression #1 of ORDER BY clause is not in ...
- MySQL [Err] 1055 - Expression #1 of ORDER BY clause is not in GROUP BY clause
MySQL[Err]1055 上次MySQL5.7.19主从建立完成之后,所有的测试都是在MySQL命令行下进行的,最近用Navicat Premium进行MySQL的连接,然后在插入数据的时候MyS ...
- 解决MySQL报错:1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column 'informat
解决MySQL报错:1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column 'informat ...
- 解决mysql报错:- Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column 'information_schema.PROFILING.SEQ'
mysql执行报错: - Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated c ...
- mysql [Err] 1055 - Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column 'information_schema.PROFILING.SEQ' which is not functionally dependent on columns in GRO
[Err] 1055 - Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated c ...
随机推荐
- The in operator
The operators we have seen so far are all special characters like + and *, but there are a few opera ...
- Idea的一些调试技巧及设置todo
程序员的工作内容,除了大部分时间写代码之外,因为有不少的时间是用在调试代码上.甚至说不是在调试代码,就是即将调试代码. :) 今天我们来谈谈调试代码的一些技巧,在使用IDE提供的debugger时一些 ...
- miniUI-SelectGrid 弹出选择表格-翻页选中
介绍 mini中已经给出 弹出表格的里例子 :MiniUi版本 但是在应用过程中遇到写小问题就是没有办法翻页后一并连之前翻页选中的一起提交 以下是解决方案 正文 下面首先介绍 JS 代码 //存储已 ...
- http://www.open-open.com/lib/tag/ReactiveCocoa
http://www.open-open.com/lib/tag/ReactiveCocoa
- NOIP2013 货车运输 倍增
问题描述 A 国有 n 座城市,编号从 1 到 n,城市之间有 m 条双向道路.每一条道路对车辆都有重量限制,简称限重.现在有 q 辆货车在运输货物,司机们想知道每辆车在不超过车辆限重的情况下,最多能 ...
- caioj 1080 动态规划入门(非常规DP4:乘电梯)(dp数组更新其他量)
我一开始是这么想的 注意这道题数组下标是从大到小推,不是一般的从小到大推 f[i]表示从最高层h到第i层所花的最短时间,答案为f[1] 那么显然 f[i] = f[j] + wait(j) + (j ...
- KM HDU 3718
#include<iostream> #include<stdio.h> #include<string.h> #include<algorithm> ...
- android 选取部分 log 的两种方法
Grep多个条件: android logcat -v time | grep -e A -e B 选取多个android log tag: android logcat -v time -s TAG ...
- UINavigationBar的系统渲染方式
昨天想手工实现一下类知乎日报的Navigation Bar的动态颜色改变,但不管怎么设置Navigation Bar的 backgroundColor barTintColor alpha參数都达不到 ...
- 7-07. PAT排名汇总(25) (结构体 ZJU_PAT)
题目链接:http://www.patest.cn/contests/ds/7-07 编程能力測试(Programming Ability Test,简称PAT)是浙江大学计算机科学与技术学院主办的专 ...