SELECT * FROM PRODUCT WHERE P_CODE = (SELECT P_CODE FROM LINE WHERE LINE_TOTAL > AVG(LINE_TOTAL));
Asked
Active
Viewed 143 times
1
-
1Please provide sample data and desired results and an explanation of what you want to do. The query doesn't make sense. – Gordon Linoff Apr 21 '21 at 00:19
-
This is the ERROR message I keep receiving. This is what i'm trying to do List all Products with a total quantity sold greater than the average quantity sold. 20:11:40 SELECT * FROM PRODUCT WHERE P_CODE = (SELECT P_CODE FROM LINE WHERE LINE_TOTAL > AVG(LINE_TOTAL)) LIMIT 0, 1000 Error Code: 1111. Invalid use of group function 0.000 sec – Bri S Apr 21 '21 at 00:21
-
Does this answer your question? [Error Code 1111. Invalid use of group function](https://stackoverflow.com/questions/22141968/error-code-1111-invalid-use-of-group-function) – Renat Apr 21 '21 at 00:27
-
@Renat I saw that but I was confused as to what to Group By I tried adding HAVING but that did not help – Bri S Apr 21 '21 at 00:30
1 Answers
0
You probably need this:
SELECT *
FROM PRODUCT
WHERE P_CODE in (SELECT P_CODE
FROM LINE
WHERE LINE_TOTAL > (select AVG(LINE_TOTAL) from LINE)
);

Renat
- 7,718
- 2
- 20
- 34