I got the following error and can't seem to debug it - any clues, ie: is there a better way to structure my sql statement perhaps ?
I am using this to create a report and have sorted it using the standard sort order. The page displays ok but when I used advanced search on po_count it gives me this error.
---------> cut here
PHP error happened
Technical information
Error type 256
Error description Invalid use of group function
URL sa-srv-mysql/sms_reports/YTD_Purchases_Report_report.php?
Error file /var/www/html/sms_reports/include/dbconnection.php
Error line 26
SQL query SELECT po.`cre_accountcode`, date_format(po.`po_order_date`,'%Y-%m-%d') AS `po_ord_date`, po.`po_whse_code`, po.`po_user_name`, Count(po.`po_order_no`) as 'po_count' FROM `Purchases`.`purchase_order` AS po WHERE (`po`.`po_backorder_flag` <'AA' AND `po`.`po_order_status` NOT IN('99') AND `po`.`po_order_date` >= subdate(curdate(), INTERVAL 3 MONTH) ) and (1=1 and upper(po.`po_whse_code`) like upper('%abne%') and Count(po.`po_order_no`)>2) GROUP BY `po`.`cre_accountcode`,`po_ord_date`,`po`.`po_whse_code`,`po`.`po_user_name` HAVING `po_count` > 1 ORDER BY 1 ASC, 3 ASC, 4 ASC, 2 ASC
---------> cut here
SQL statement is as follows :
------->
SELECT
po.`cre_accountcode`,
date_format(po.`po_order_date`,'%Y-%m-%d') AS `po_ord_date`,
po.`po_whse_code`,
po.`po_user_name`,
Count(po.`po_order_no`) as 'po_count'
FROM `Purchases`.`purchase_order` AS po
WHERE `po`.`po_backorder_flag` <'AA'
AND `po`.`po_order_status` NOT IN('99')
AND `po`.`po_order_date` >= subdate(curdate(), INTERVAL 3 MONTH)
GROUP BY `po`.`cre_accountcode`,`po_ord_date`,`po`.`po_whse_code`,`po`.`po_user_name`
HAVING `po_count` > 1
------>
Thanks in anticipation of your help (I think the word brilliance gets over used don't you <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=question&id=5642&image=1&table=forumtopics' class='bbc_emoticon' alt=':P' /> )
Cheers,
slobbering_dog