analyticdb(ADB) group by 用法小结

虽说analyticdb(ADB)是支持mysql协议的,但有些具体细节用法是有些区别。

1.group by 字段

mysql group by

select id,title,describe

where table_a

group by id,title

mysql中group的字段可以多余或少于select中的字段

但在adb中,gruop的字段必须大于等于select中字段

select id,title,describe

where table_a

group by id,title,describe,other

2.adb中排序问题

排序在mysql数据库中是一个默认不会引起注意的东西,因为在mysql中数据是按主键递增存储的,已包含排序。

但在adb中,创建表需要指定多个字段共同作用,例:PRIMARY KEY (id,title,other),所以排序就要特别注意。

在adb中id是可以重复的,所以在正常的获取数据以及group中都需要注意加上排序。

例:

select id,title,describe

where table_a

group by id,title,describe

order by id,title,describe

原文地址:https://www.cnblogs.com/rainersha/p/11190135.html