Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

14.A. Find the item titles and the corresponding order ids. HERE ITEMS , ORDER_D

ID: 3788794 • Letter: 1

Question

14.A. Find the item titles and the corresponding order ids.

HERE ITEMS , ORDER_DETAILS TABLE CONTAIN

SELECT TITLE, ORDER_ID
FROM ITEMS I FULL JOIN ORDER_DETAILS D
ON I.ITEM_ID = D.ITEM_ID

  

B. Now count the number of orders ach item has been included in.

BUT HOW DO I COUNT (ORDER_id)

I TRY

SELECT TITLE, ORDER_ID, COUNT(ORDER_ID)
FROM ITEMS I FULL JOIN ORDER_DETAILS D
ON I.ITEM_ID = D.ITEM_ID

GROUP BY ORDER_ID;

BUT RESULT IS NOT COME OUT

C. Now report only those items that have been included in more than 5 different orders

SELECT TITLE, ORDER_ID
FROM ITEMS I FULL JOIN ORDER_DETAILS D
ON I.ITEM_ID = D.ITEM_ID
WHERE D.ORDER_DETAILS >5;
  
SAME NO RESULT

Explanation / Answer

B)

count the number of orders ach item has been included in.

U CAN USE BELOW QUERRY FOR THAT


SELECT TITLE, ORDER_ID, COUNT(ORDER_ID)
FROM ITEMS I FULL JOIN ORDER_DETAILS D
ON I.ITEM_ID = D.ITEM_ID
GROUP BY ORDER_ID,TITLE;


C)

Now report only those items that have been included in more than 5 different orders


SELECT TITLE, ORDER_ID,COUNT(D.ORDER_DETAILS)
FROM ITEMS I FULL JOIN ORDER_DETAILS D
ON I.ITEM_ID = D.ITEM_ID
GROUP BY TITLE,ORDER_ID
HAVING COUNT(D.ORDER_DETAILS) >5;

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote