This query displays the product ID, product description, and total quantity of products sold together with product ID 201 that were not shipped to the cities of Bangalore and New Delhi. It uses a subquery to filter for order IDs associated with product 201 before joining tables and grouping by product ID and description and sorting the total quantity in descending order.
This query displays the product ID, product description, and total quantity of products sold together with product ID 201 that were not shipped to the cities of Bangalore and New Delhi. It uses a subquery to filter for order IDs associated with product 201 before joining tables and grouping by product ID and description and sorting the total quantity in descending order.
This query displays the product ID, product description, and total quantity of products sold together with product ID 201 that were not shipped to the cities of Bangalore and New Delhi. It uses a subquery to filter for order IDs associated with product 201 before joining tables and grouping by product ID and description and sorting the total quantity in descending order.
Write a query to display product_id, product_desc and total quantity of products
which are sold together with product id 201 and are not shipped to city Bangalore and New Delhi. Display the output in descending order with respect to the tot_qty. -- (USE SUB-QUERY) -- [NOTE: TABLES to be used - order_items, product,order_header, online_customer, address]
select pro.PRODUCT_ID,pro.PRODUCT_DESC,sum(ol.PRODUCT_QUANTITY) as total_quantity
from product pro
join order_items ol on pro.PRODUCT_ID=ol.PRODUCT_ID
join order_header ohl on ol.ORDER_ID=ohl.ORDER_ID
join online_customer ocl on ohl.CUSTOMER_ID=ocl.CUSTOMER_ID
join address ad on ocl.ADDRESS_ID=ad.ADDRESS_ID
where ol.ORDER_ID in (select ol.ORDER_ID from order_items where PRODUCT_ID='201' and
ohl.ORDER_STATUS='shipped' and ad.CITY not in ('Bangalore','New Delhi') )