So I'm supposed to create a view product_view that presents the information about how many products of a particular type are in each warehouse: product ID, product name, category_id, warehouse id, total quantity on hand for this warehouse.
So I used this query and tried to change it so many times but I keep getting errors
CREATE OR REPLACE VIEW PRODUCT_VIEW AS
SELECT p.product_id, p.product_name,
COUNT(p.product_id), SUM(i.quantity_on_hand)
FROM oe.product_information p JOIN oe.inventories i
ON p.product_id=i.product_id
ORDER BY i.warehouse_id;
ERROR at line 2: ORA-00928: missing SELECT keyword
Please help... Thanks
Image showing the Tables in the OE schema Image showing the error that occurs
When I get errors creating a view, I firstly drop the CREATE ... AS
line and fix the query until it works. Then you need to name all the columns, for instance COUNT(p.product_id)
won't work, you'll need to write something like COUNT(p.product_id) AS product_count
or specify a list of aliases, like so
I'm not sure what the output of your query should look like. You'll get better answers quicker on stackexchange if you type a minimal example including the CREATE statments, some input data and your desired output, leaving out columns that are not essential.