I'm trying to build a query that has a group by
attribute,
im truing to get the id
and the count
it keeps telling me that the count (*)
is invalid column name
how could i get the count
from the group by
query ??
Work's with alias. Yii 1.1.11. Fails other
$criteria= new CDbCriteria();
$criteria=array(
'group'=>'attribute',
'select'=>'id,count(*) AS cc'
);
This not exactly an answer to your question, but could still be useful for you. If you use the result to only look up one count for one specific attribute, you don't need to fecth an entire array, but use Yii's count
method:
$criteria= new CDbCriteria();
$criteria.compare('col_name', $desired_col_value);
$count = X::model()->count($criteria);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With