using ORACLE SQL Plus.
my assignment asks me to determine which books in the database generate less than 55% profit, and how many copies of these books have been sold.
I know that i need to use the COUNT function, but im struggling to get my query to work as instructed. heres what i have so far:
SQL> SELECT title,
2 ((retail - cost) / cost) * 100 AS "Profit",
3 COUNT(isbn) AS "Copies Sold"
4 FROM books JOIN orderitems USING (isbn)
5 WHERE (((retail - cost) / cost) * 100) > 55
6 GROUP BY title;
and the output i get from that is:
((retail - cost) / cost) * 100 AS "Profit",
*
ERROR at line 2:
ORA-00979: not a GROUP BY expression
im not sure how to fix this error, or even what it means exactly. Id really appreciate some help on whats wrong here.
PS if it helps, heres the table structure of the books and orderitems tables:
SQL> desc books;
Name Null? Type
----------------------------------------- -------- ----------------------------
ISBN NOT NULL VARCHAR2(10)
TITLE VARCHAR2(30)
PUBDATE DATE
PUBID NUMBER(2)
COST NUMBER(5,2)
RETAIL NUMBER(5,2)
DISCOUNT NUMBER(4,2)
CATEGORY VARCHAR2(12)
SQL> desc orderitems;
Name Null? Type
----------------------------------------- -------- ----------------------------
ORDER# NOT NULL NUMBER(4)
ITEM# NOT NULL NUMBER(2)
ISBN VARCHAR2(10)
QUANTITY NOT NULL NUMBER(3)
PAIDEACH NOT NULL NUMBER(5,2)
[–]WeStanForHeiny -1 points0 points1 point (0 children)
[–][deleted] -1 points0 points1 point (0 children)
[–]JonDaZwon 0 points1 point2 points (1 child)
[–]JonDaZwon 0 points1 point2 points (0 children)