Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Aprende Obtener Categoría Por Precio de Producto | Uniendo Tablas
SQL Intermedio

book
Obtener Categoría Por Precio de Producto

Excelente, hemos obtenido la cantidad de productos en cada categoría. Ahora necesitamos recuperar las categorías donde los productos cuestan más de cierta cantidad de dinero.

Solo un recordatorio de que estamos trabajando con dos tablas.

product:

Tarea

Swipe to start coding

Your task is to retrieve the unique category names that have products with a price higher than 450. Use the WHERE clause for this, where you compare 450 with the value of the price column.

There should be only one column in the output - category.name. You do not include the price column in the SELECT section; you only use it in the WHERE section.

Brief Instructions

  • Retrieve the category.name column from the category table.
  • Use DISTINCT to get only unique values.
  • Join the product table using a JOIN statement.
  • The common column for both tables is category.id = product.category_id.
  • Use a WHERE clause with the condition price > 450.

Solución

SELECT DISTINCT category.name
FROM category
JOIN product
ON category.id = product.category_id
WHERE price > 450;
¿Todo estuvo claro?

¿Cómo podemos mejorarlo?

¡Gracias por tus comentarios!

Sección 3. Capítulo 2

Query ResultQuery Result
No query executed yet...

Pregunte a AI

expand
ChatGPT

Pregunte lo que quiera o pruebe una de las preguntas sugeridas para comenzar nuestra charla

some-alt