SQLSTATE[42S22]: Column not found: 1054 Unknown column 'SUM((IFNULL(main_table.base_total_invoiced, 0) - IFNULL(main_table.base_tax_invoiced, 0) - IFNULL(main_table.base_shipping_invoiced, 0) - (IFNULL(main_table.base_total_refunded, 0) - IFNULL(ma' in 'field list',
查询是:
SELECT `SUM((IFNULL(main_table.base_total_invoiced, 0) -
IFNULL(main_table.base_tax_invoiced, 0) -
IFNULL(main_table.base_shipping_invoiced, 0) -
(IFNULL(main_table.base_total_refunded, 0) -
IFNULL(main_table.base_tax_refunded, 0) -
IFNULL(main_table.base_shipping_refunded, 0))) *
main_table`.`base_to_global_rate)` AS `lifetime`,
`AVG((IFNULL(main_table.base_total_invoiced, 0) -
IFNULL(main_table.base_tax_invoiced, 0) -
IFNULL(main_table.base_shipping_invoiced, 0) -
(IFNULL(main_table.base_total_refunded, 0) -
IFNULL(main_table.base_tax_refunded, 0) -
IFNULL(main_table.base_shipping_refunded, 0))) *
main_table`.`base_to_global_rate)` AS `average` FROM
`sales_flat_order` AS `main_table` WHERE (main_table.status NOT
IN('canceled')) AND (main_table.state NOT IN('new',
'pending_payment'))
当我打开Magento管理面板仪表板时,出现此错误。
提前致谢
答案 0 :(得分:0)
查询时出错,它不应该在引号内包含sql函数。请尝试以下查询。
SELECT SUM((
IFNULL(main_table.base_total_invoiced, 0) -
IFNULL(main_table.base_tax_invoiced, 0) -
IFNULL(main_table.base_shipping_invoiced, 0) -
IFNULL(main_table.base_total_refunded, 0) -
IFNULL(main_table.base_tax_refunded, 0) -
IFNULL(main_table.base_shipping_refunded, 0))) *
main_table.base_to_global_rate AS `lifetime`,
AVG((
IFNULL(main_table.base_total_invoiced, 0) -
IFNULL(main_table.base_tax_invoiced, 0) -
IFNULL(main_table.base_shipping_invoiced, 0) -
IFNULL(main_table.base_total_refunded, 0) -
IFNULL(main_table.base_tax_refunded, 0) -
IFNULL(main_table.base_shipping_refunded, 0))) *
main_table.base_to_global_rate AS `average`
FROM `sales_flat_order` AS `main_table`
WHERE (main_table.status NOT IN('canceled'))
AND (main_table.state NOT IN('new', 'pending_payment'))