select n.customer_id
from (select COUNT(customer_id) 数量, customer_id from T1123 group by customer_id) n
where n.数量 = (select MAX(数量) from (select COUNT(customer_id) 数量, customer_id from T1123 group by customer_id) m)
select customer_id
from (select customer_id, rank() over (order by t desc) r
      from (select customer_id, count(1) t from T1123 group by customer_id) a) b
where b.r = 1;
                    select order_id, count(1) cntfrom (         select order_id         from t1123         union all         select customer_id         from t1123) agroup by order_idhaving cnt in (select max(cnt)               from (                        selec...
+-----------------+----------+
| Column Name     | Type     |
+-----------------+----------+
| order_number    | int      |
| customer_number | int      |
+-----------------+----------+
Order_number是该表的主
+-----------------+----------+
| Column Name     | Type     |
+-----------------+----------+
| order_number    | int      |
| customer_number | int      |
+-----------------+----------+
关于mysql之前学习的零零散散,这次基于mysql8.0进行归零式(从基础SQL出发)总结和学习,但内容不会涉及到DBA那种细粒度,只从开发角度,熟悉其需要了解的内容
数据库设计简介
首先从数据库设计出发,说明数据库设计中的一些问,在大学数据库设计概要这么课程中,详细介绍过如果将需求变成E-R数据模型,这个内容在网上也能找到很多资料,这里不会去总结这个。可以参考如下大佬的博客。
E-R关系设计介绍。
良好的数据库设计是数据库获得高性能的基础。一般的数据库设计分为如下几个步骤:1、需求分析,2、逻辑