`

mysql 5.7Expression #1 of ORDER BY clause is not in SELECT list

阅读更多

 

java.sql.SQLException: Expression #1 of ORDER BY clause is not in SELECT list, references column 'amc.ti.create_time' which is not in SELECT list; this is incompatible with DISTINCT

 

  今天遇到一个问题,一个sql可以在mysql5.6运行,不能在mysql5.7运行。百度说,可以修改my.cnf,但是mac的mysql没有这配置。继续百度,

http://bbs.csdn.net/topics/391878172page=1,

 http://blog.sina.com.cn/s/blog_4f925fc30102e0ot.html

 

上面句子正确写法:SELECT T.NAME FROM UNIT T WHERE ROWNUM < 10 ORDER BY T.UNITNO;

                  或者                 

                  SELECT DISTINCT T.NAME,T.UNITNO FROM UNIT T WHERE ROWNUM < 10 ORDER BYT.UNITNO;

 

【注】:加DISTINCT后是把数据先放到一个DISTINCT后的临时集合里然后再进行排序。

 

 

分享到:
评论

相关推荐

    MySQL异常:[Err] 1055 – Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nona…

    在MySQL中,错误提示 "[Err] 1055 – Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column…” 指的是在执行包含`GROUP BY`子句的查询时,你试图对未在`GROUP BY`子句中...

    mysql遇到Expression.docx

    在MySQL中,当你尝试执行一个包含`GROUP BY`子句的查询时,可能会遇到"Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column"这样的错误。这个错误提示表明你的查询违反了`...

    MySQL5.7中的sql_mode默认值带来的坑及解决方法

    在正常项目开发过程中,如果MySQL版本从5.6升级到5.7版本。作为DBA在考虑数据库版本升级带来的影响时,一般会有几个注意点...ERROR 1055 (42000): Expression #3 of XXXXXX list is not in GROUP BY clause and contain

    解决大于5.7版本mysql的分组报错Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated

    如果`SELECT`列表中的列没有出现在`GROUP BY`子句中,且该列没有被聚合函数(如`SUM`, `AVG`, `MAX`, `MIN`等)处理,MySQL会抛出`Expression #1 of SELECT list is not in GROUP BY clause and contains ...

    mysql不支持group by的解决方法小结

    然而,在MySQL 5.7.x及更高版本中,默认启用了`ONLY_FULL_GROUP_BY`模式,这导致了对`GROUP BY`语句更为严格的解释。在`ONLY_FULL_GROUP_BY`模式下,所有出现在`SELECT`列表中但未包含在`GROUP BY`子句的列必须是...

    解决MySQL 5.7.9版本sql_mode=only_full_group_by问题

    Expression #2 of SELECT list is not in GROUP BY clause and contains nonaggregated column ‘col_user_6.a.START_TIME’ which is not functionally dependent on columns in GROUP BY clause; this is ...

    MySQL使用中遇到的问题记录

    当MySQL执行GROUP BY查询时,如果SELECT列表中包含未在GROUP BY中指定的非聚合列,且该列未包含在聚合函数(如SUM、AVG等)中,就会报错。解决这个问题的方法是调整`sql_mode`的设置。你可以通过登录MySQL并运行以下...

    Mysql升级到5.7后遇到的group by查询问题解决

    错误提示 "SELECT list is not in GROUP BY clause and contains nonaggregated column 'news.id' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_...

    MYSQL数据查询技巧.pdf

    最后,当遇到ORDER BY错误,错误信息提示"Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column...",这是由于SQL模式"only_full_group_by"的要求,该模式下,ORDER BY...

    SQL Server 2012 Transact-SQL DML Reference

    - `SELECT column_name, SUM(column_name) OVER (ORDER BY column_name ROWS BETWEEN 1 PRECEDING AND CURRENT ROW) AS rolling_sum FROM table_name;` #### Table Value Constructor 表值构造器用于创建临时表,...

    springclouddemo

    1. **Eureka**:Eureka是Spring Cloud中的核心组件之一,它作为一个服务注册中心,负责管理各个微服务实例的生命周期。当服务启动时,它们会向Eureka注册,并定时发送心跳来证明其存活状态。同时,其他服务通过...

    delphi 错误大全

    #### '&lt;clause&gt;' clause not allowed in OLE automation section **错误描述:** 如果在 OLE 自动化代码块中使用了不允许的子句,会触发此错误。 **解决办法:** 检查并确认所有在 OLE 自动化部分使用的子句都是...

    MySQL5.7更改密码时出现ERROR 1054 (42S22)的解决方法

    新安装的MySQL5.7,登录时提示密码错误...in ‘field list’,原来是mysql数据库下已经没有password这个字段了,password字段改成了authentication_string 所以更改语句替换为update mysql.user set authentication_st

    SSD7 选择题。Multiple-Choice

    (a) filling in skeleton tables of the database with examples of what is to be retrieved (b) placing SQL keywords, such as select, under the column names they want to retrieve (c) typing a ...

    微软内部资料-SQL性能优化5

    The order of pages in the page chain, and the order of rows on the data pages, is the order of the index key or keys. Deciding which key to cluster on is an important performance consideration. When ...

    MySql存储过程编程.chm

    Tuning ORDER and GROUP BY Section 21.5. Tuning DML (INSERT, UPDATE, DELETE) Section 21.6. Conclusion Chapter 22. Optimizing Stored Program Code Section 22.1. Performance Characteristics of ...

    编程错误英汉互译

    'clause' not allowed in OLE automation section 错误描述:在OLE自动化部分中不允许使用特定子句。 解决方法:仔细检查与OLE相关的代码段,确认是否在自动化部分不当使用了某些子句,应遵循OLE自动化规范进行调整...

Global site tag (gtag.js) - Google Analytics