在數(shù)據(jù)庫模型或者調(diào)用數(shù)據(jù)庫時(shí),有根據(jù)分組求最大值,最小值或平均值的方法嗎?
比如:使用keyword_id來分組,求id最大值,除了sql語句,max(id)怎么寫進(jìn)去的?
$this->table('keyword_rank')
->where($where)
->group_by('keyword_id')
->order_by('inputtime DESC')
->get_all();
$this->table('keyword_rank') ->select('max(id) as maxid') ->where($where) ->group_by('keyword_id') ->order_by('inputtime DESC') ->get_all();開源是一種精神,但不是義務(wù),幫忙是情分,不幫也不要抱怨,建議大家多研究代碼、多閱讀代碼、多翻閱社區(qū)歷史問題!