count(*)與count(column-name)這兩個示例相比,這樣做是否有所不同?我傾向于總是寫,count(*)因為如果可行,它似乎更適合我的想法,因為它是一個聚合函數(shù)。但是我不確定這在技術上是否最好,因為我傾向于看到示例代碼編寫時*經(jīng)常沒有。計數(shù)(*):select customerid, count(*), sum(price) from items_orderedgroup by customeridhaving count(*) > 1;vs. count(列名):SELECT customerid, count(customerid), sum(price)FROM items_orderedGROUP BY customeridHAVING count(customerid) > 1;
count(*)vs count(列名)-哪個更正確?
浮云間
2019-11-27 10:57:56