mysql - SQL语句使用聚合函数之后有些字段没有分组显示,那它显示的规则是什么?
ringa_lee
ringa_lee 2017-04-17 13:44:49
0
1
841
ringa_lee
ringa_lee

ringa_lee

reply all(1)
刘奇

Will the field hk.backMoney display the data corresponding to the largest hk.backTime?

Because you used Group By, the largest hk.backTime under the same userInfoId is displayed

After using aggregate functions on multiple fields, if the other fields are not grouped, there will only be one. How are the other fields obtained?

The method of selecting other fields is related to the specific implementation of the database you use. It may be sorted by default or returned randomly, so generally speaking, Select non-aggregated fields are meaningless in aggregate queries. If you want to achieve something like retrieving a user's most recent operation record, you need to wrap another layer of query statements outside.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!