Home > Back-end >  Query to show the product categories that contains more than 1 product with price higher than 10
Query to show the product categories that contains more than 1 product with price higher than 10

Time:09-22

How to make a SQL Query to show the product categories that contains more than 1 product with price higher than 10

The table "Product" of a database contains the columns

NAME VARCHAR2(256) NOT NULL, 
CATEGORIE VARCHAR2(64) NOT NULL 
PRICE NUMBER(9,2) NOT NULL

Follow this example of database:

NAME    CATEGORIE   PRICE 
BREAD   BAKERY       3.00 
CHEESE  BAKERY      25.00 
MEAT    BUTCHERY    23.00
PORK    BUTCHERY    41.00
SOAP    CLEANING    15.00

In this case, the query will return only "BUTCHERY" because it's the only categorie that contains more than 1 product with the price higher than 10.

CodePudding user response:

select CATEGORIE
from Product
where price > 10
group by CATEGORIE
having count(*) > 1
  • Related