I want something like this:
$res = Model::find('all', array(
'fields' => array(
'SUM(col1)' => array(
'alias' => 'col1_total',
),
'SUM(col2)' => array(
'alias' => 'col2_total',
)
)
);
expected generated SQL:
SELECT SUM(col1) AS col1_total, SUM(col2) AS col2_total
FROM `tbl` AS `Model` WHERE 1;
I tried many ways. is this possible?
a working example for a single col:
$res = Model::find('all', array(
'fields' => 'SUM(col1)'
)
);
Cool!
working example:
$res = Model::find('all', array(
'fields' => array(
'SUM(col1) AS col1_total',
'SUM(col2) AS col2_total'
)
);