关于postgresql group by 报错
Before SQL3 (1999), the selected fields must appear in the GROUP BY clause[*].Interestingly enough,
even though the spec sort of allows to select non-grouped fields, major engines seem to not really like it.
Oracle and SQLServer just don't allow this at all. Mysql used to allow it by default, but now since 5.7 the
administrator needs to enable this option (ONLY_FULL_GROUP_BY) manually in the server configuration
for this feature to be supported.
SELECT m.cname, m.wmname, t.mx FROM ( SELECT cname, MAX(avg) AS mx
FROM makerar GROUP BY cname ) t
JOIN makerar m ON m.cname = t.cname AND t.mx = m.avg ;
SELECT DISTINCT /* distinct here matters, because maybe there are various tuples for the same max
value */ m.cname, m.wmname, t.avg AS mx FROM ( SELECT cname, wmname, avg, ROW_NUMBER()
OVER (PARTITION BY avg DESC) AS rn FROM makerar ) t JOIN makerar m ON m.cname = t.cname AND
m.wmname = t.wmname AND t.rn = 1 ;
SELECT DISTINCT ON (cname) cname, wmname, avg FROM makerar ORDER BY cname, avg DESC ;
关于postgresql group by 报错的更多相关文章
- mysql 5.7.28 中GROUP BY报错问题 SELECT list is not in GROUP BY clause and contains no
----mysql 5.7.28 中GROUP BY报错问题 SELECT list is not in GROUP BY clause and contains no------ 解决方案: sel ...
- mysql group by 报错异常解决
mysql报错及其解决方式 1.在使用group by 查询一张表的数据的时候:select date,time,max(delaytime) as delaytime,sum(delaynum) a ...
- mysql group by 报错 ,only_full_group_by 三种解决方案
报错信息 Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'data ...
- PostgreSQL 修改列报错:cannot be cast automatically to type integer
如果你直接使用可视化工具修改一个varchar字段为int类型的时候,可能会报错, 这里就需要自己去写一个语句去修改了 调整执行语句:ALTER TABLE table_name ALTER COLU ...
- Postgresql重安装报错The database cluster initialisation failed.
之前安装过PostgreSQL-9.6.5,卸载后,重装PostgreSQL-9.1.3版本,报错. 清除注册表,删除postgres账户,清除垃圾后,再次安装仍然报错. 最后改变默认安装路径,神奇的 ...
- MySQL报错注入函数汇总及常用注入语句
版权声明:本文转载自网络内容,下面附原创链接原创链接:https://blog.csdn.net/Auuuuuuuu/article/details/91415165 常用函数 字符串连接函数,将多个 ...
- CTF-sql-group by报错注入
本文章主要涉及group by报错注入的原理讲解,如有错误,望指出.(附有目录,如需查看请点右下角) 一.下图为本次文章所使用到 user表,该表所在的数据库为 test 二.首先介绍一下本文章所使用 ...
- 学习笔记 MYSQL报错注入(count()、rand()、group by)
首先看下常见的攻击载荷,如下: select count(*),(floor(rand(0)*2))x from table group by x; 然后对于攻击载荷进行解释, floor(rand( ...
- 【PostgreSQL】PostgreSQL添加新服务器连接时,报错“Server doesn't listen ”,已解决。
PostgreSQL添加新的服务器连接时,报错:
随机推荐
- The base and high address of the custom IP are not correctly reflected in xparameters.h in SDK
This issue has been observed in 2015.3, 2015.4, and 2015.4.1 builds of Vivado. When you create and a ...
- 创建Git 仓库及 克隆、拉取、和推送操作
打开网址: https://github.com/ 登录上自己创建的 Git账号 一. 创建Git 仓库 start a project---> 输入仓库 ...
- TensorFlow object detection API
cloud执行:https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/running_pet ...
- Lesson 1-2
1.5 模块 模块可视为扩展,通过将其导入可以扩展python的功能.python中自带有一组模块,也称为“标准库”. 1.5.1 模块的导入:import + 模块名称 • 使用关键字import导 ...
- C++智能指针剖析(上)std::auto_ptr与boost::scoped_ptr
1. 引入 C++语言中的动态内存分配没有自动回收机制,动态开辟的空间需要用户自己来维护,在出函数作用域或者程序正常退出前必须释放掉. 即程序员每次 new 出来的内存都要手动 delete,否则会造 ...
- .net基础学java系列(二)IDE 之 插件
上一篇文章.net基础学java系列(二)IDE "扎实的基础"+"宽广的视野",基本可以帮我们摆脱码畜.码奴.码农的命运! IT领袖:IT大哥:IT精英:IT ...
- android---EditText的多行输入框
<EditText android:id="@+id/edt_order_note_text" android:layout_width="match_parent ...
- java中读取资源文件的方法
展开全部 1.使用java.util.Properties类的load()方法 示例: //文件在项目下.不是在包下!! InputStream in = new BufferedInputStrea ...
- Scrapyd 改进第二步: Web Interface 添加 STOP 和 START 超链接, 一键调用 Scrapyd API
0.提出问题 Scrapyd 提供的开始和结束项目的API如下,参考 Scrapyd 改进第一步: Web Interface 添加 charset=UTF-8, 避免查看 log 出现中文乱码,准备 ...
- lxml爬取实验
1.豆瓣 爬取单个页面数据 import requests from lxml import etree #import os url = "https://movie.douban.com ...