count(*)与count(column-name)这两个示例相比,这样做是否有所不同?
我倾向于总是写,count(*)因为如果可行,它似乎更适合我的想法,因为它是一个聚合函数。
但是我不确定这在技术上是否最好,因为我倾向于看到示例代码编写时*经常没有。
计数(*):
select customerid, count(*), sum(price)
from items_ordered
group by customerid
having count(*) > 1;
vs. count(列名):
SELECT customerid, count(customerid), sum(price)
FROM items_ordered
GROUP BY customerid
HAVING count(customerid) > 1;
茅侃侃
冉冉说
湖上湖
相关分类