i-net Ver.7 "SQL Statement is not a SELECT, CALL, or EXEC Statement!" when I...

alexis b

New member
...use () to enclose a query? I used this query to show the top 5 brand names for every month of the first quarter that were bought by GOLDEN card members

(SELECT month_of_year,the_month, member_card, brand_name, SUM(units_ordered) AS orders, SUM(store_sales) AS sales
FROM inventory_fact_1997 INNER JOIN time_by_day
ON inventory_fact_1997.time_id=time_by_day.time_id
INNER JOIN product ON product.product_id=inventory_fact_1997.product_id
INNER JOIN sales_fact_1997 ON sales_fact_1997.product_id=inventory_fact_1997.product_id
INNER JOIN customer ON customer.customer_id=sales_fact_1997.customer_id
WHERE the_month="January" AND
member_card="Golden"
GROUP BY month_of_year,the_month, member_card, brand_name
ORDER BY sales DESC
LIMIT 5
UNION
SELECT month_of_year,the_month, member_card, brand_name, SUM(units_ordered) AS orders, SUM(store_sales) AS sales
FROM inventory_fact_1997 INNER JOIN time_by_day
ON inventory_fact_1997.time_id=time_by_day.time_id
INNER JOIN product ON product.product_id=inventory_fact_1997.product_id
INNER JOIN sales_fact_1997 ON sales_fact_1997.product_id=inventory_fact_1997.product_id
INNER JOIN customer ON customer.customer_id=sales_fact_1997.customer_id
WHERE the_month="February" AND
member_card="Golden"
GROUP BY month_of_year,the_month, member_card, brand_name
ORDER BY sales DESC
LIMIT 5)
UNION
(SELECT month_of_year,the_month, member_card, brand_name, SUM(units_ordered) AS orders, SUM(store_sales) AS sales
FROM inventory_fact_1997 INNER JOIN time_by_day
ON inventory_fact_1997.time_id=time_by_day.time_id
INNER JOIN product ON product.product_id=inventory_fact_1997.product_id
INNER JOIN sales_fact_1997 ON sales_fact_1997.product_id=inventory_fact_1997.product_id
INNER JOIN customer ON customer.customer_id=sales_fact_1997.customer_id
WHERE the_month="March" AND
member_card="Golden"
GROUP BY month_of_year,the_month, member_card, brand_name
ORDER BY sales DESC
LIMIT 5)
 
Back
Top