-1

I am trying to use COUNT to well count the number of times a product has been ordered.

Below is what I have,which is not working out. I get the error

SQL Error: ORA-00937: not a single-group group function

When I try to use the Group by function it said it's not a GROUP by function or that it cannot be used.

CREATE OR REPLACE VIEW product_summary AS
    SELECT product_name, COUNT(*) AS order_count, item_total AS order_total
    FROM order_item_products
Ken White
  • 123,280
  • 14
  • 225
  • 444
cmw
  • 23
  • 2

1 Answers1

1

I think the error is pretty clear. Add group by:

CREATE OR REPLACE VIEW product_summary AS
    SELECT product_name, COUNT(*) AS order_count,
           SUM(item_total) AS order_total
    FROM order_item_products
    GROUP BY product_name;
Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786