当我在 mysql 编辑器上运行它时,我有以下查询,它在 jasper 报告中使用它时给出“无效使用 group by”的错误,它不会产生任何错误?查询有什么问题?
SELECT CUSTOMERS.TAXID,
CUSTOMERS.NAME AS CUSTOMER,
CATEGORIES.NAME AS CATEGORY,
PRODUCTS.REFERENCE,
PRODUCTS.NAME AS PRODUCT,
SUM(TICKETLINES.UNITS) AS UNIT,
SUM(TICKETLINES.UNITS * TICKETLINES.PRICE) AS TOTAL,
SUM(TICKETLINES.UNITS * TICKETLINES.PRICE) / SUM(TICKETLINES.UNITS) AS MEANPRICE,
PRODUCTS.PRICEBUY AS BUYPRICE,
((SUM(SUM(TICKETLINES.PRICE) / SUM(TICKETLINES.UNITS)) - PRODUCTS.PRICEBUY) * TICKETLINES.UNITS) AS PROFITLOSS
FROM TICKETS
LEFT OUTER JOIN CUSTOMERS ON TICKETS.CUSTOMER = CUSTOMERS.ID, TICKETLINES
LEFT OUTER JOIN PRODUCTS ON TICKETLINES.PRODUCT = PRODUCTS.ID
LEFT OUTER JOIN CATEGORIES ON PRODUCTS.CATEGORY = CATEGORIES.ID
WHERE RECEIPTS.ID = TICKETS.ID AND
TICKETS.ID = TICKETLINES.TICKET AND
CATEGORIES.ID = PRODUCTS.CATEGORY
GROUP BY CUSTOMERS.ID, CATEGORIES.ID, PRODUCTS.ID
ORDER BY CUSTOMERS.NAME,
CATEGORIES.NAME,
PRODUCTS.NAME