题目链接:点击打开链接
题目大意:略。
解题思路:解决方案(2)比解决方案(1)更优雅,是因为对 ORDER BY 和 GROUP BY 的理解执行顺序没到位。
AC 代码
--解决方案(1) SELECTcustomer_numberFROM (SELECTcustomer_number, COUNT(customer_number) cntFROMordersGROUPBYcustomer_number) RSORDERBYcntDESCLIMIT1; --解决方案(2) SELECTcustomer_numberFROMordersGROUPBYcustomer_numberORDERBYCOUNT(*) DESCLIMIT1;