Problem : List number of products per product category
Output the CATEGORY_NAME (name field in product_category table) and PRODUCT_COUNT
SQL
SELECT pc.name AS CATEGORY_NAME, count(*) AS PRODUCT_COUNT
FROM product p, product_category pc
WHERE p.product_category_id = pc.product_category_id
GROUP BY pc.product_category_id
Output the CATEGORY_NAME (name field in product_category table) and PRODUCT_COUNT
SQL
SELECT pc.name AS CATEGORY_NAME, count(*) AS PRODUCT_COUNT
FROM product p, product_category pc
WHERE p.product_category_id = pc.product_category_id
GROUP BY pc.product_category_id
No comments:
Post a Comment
Note: only a member of this blog may post a comment.