0
votes
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', 

query was:

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'))

When I am open Magento admin panel dashboard, getting this error.

Thanks in advance

1
Are you trying to debug Magento or is this a coding problem? - Enigmativity

1 Answers

0
votes

It's error with query, it should not include sql function within quotes '. Try below query.

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'))