Reputation: 2207
I'm trying to get a value from a DB but this value is not correct so I wanted to change it (in this case divide by 100) but I can't make it to work.
$query->select([new \yii\db\Expression("sum(('c.api_sales_price') / 100) AS api_sales_price"),])->all();
Upvotes: 0
Views: 197
Reputation: 22174
You have unnecessary quotes - 'c.api_sales_price'
is treated as value not a column name:
$query->select([
new \yii\db\Expression('sum(c.api_sales_price / 100) AS api_sales_price'),
])
->all();
Upvotes: 1