當我在mysql編輯器上運行它時發生以下查詢,它在jasper報告中使用它時給出「group by by invalid by error」的錯誤,它不會產生任何錯誤?查詢有什麼問題?在mySql中使用Group無效
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
你在一個叫做'RECEIPTS'表中增加條件,但它不是隨時隨地加入。 –