SQL List the item ID, description, and category for each pair of items that are in the same category. (For example, one such pair would be item FS42 and item PF19, because the category for both items...


SQL


List the item ID, description, and category for each pair of items that are in the same category. (For example, one such pair would be item FS42 and item PF19, because the category for both items is FSH.) Order the output by category.


I have this hint, but I cannot figure out what to write within the HAVING clause:



SELECT CATEGORY, ITEM_ID, DESCRIPTION

  FROM ITEM

 WHERE EXISTS (SELECT COUNT(*) FROM ITEM I

                      WHERE I._____________ = ITEM._______________

                      GROUP BY CATEGORY

                      HAVING ___________________)

ORDER BY ________________;




ITEM_ID<br>DESCRIPTION<br>ON_HAND<br>CATEGORY<br>LOCATION<br>PRICE<br>AD72<br>Dog Feeding Station<br>12<br>DOG<br>B<br>79.99<br>BC33<br>Feathers Bird Cage (12x24x18)<br>10<br>BRD<br>В<br>79.99<br>CA75<br>Enclosed Cat Litter Station<br>15<br>CAT<br>39.99<br>DT12<br>Dog Toy Gift Set<br>27<br>DOG<br>B<br>39.99<br>FM23<br>Fly Mask with Ears<br>41<br>HOR<br>24.95<br>FS39<br>Folding Saddle Stand<br>12<br>HOR<br>39.99<br>FS42<br>Aquarium (55 Gallon)<br>FSH<br>A<br>124.99<br>KH81<br>Wild Bird Food (25 Ib)<br>24<br>BRD<br>19.99<br>LD14<br>Locking Small Dog Door<br>14<br>DOG<br>A<br>49.99<br>LP73<br>Large Pet Carrier<br>23<br>DOG<br>B<br>59.99<br>

Extracted text: ITEM_ID DESCRIPTION ON_HAND CATEGORY LOCATION PRICE AD72 Dog Feeding Station 12 DOG B 79.99 BC33 Feathers Bird Cage (12x24x18) 10 BRD В 79.99 CA75 Enclosed Cat Litter Station 15 CAT 39.99 DT12 Dog Toy Gift Set 27 DOG B 39.99 FM23 Fly Mask with Ears 41 HOR 24.95 FS39 Folding Saddle Stand 12 HOR 39.99 FS42 Aquarium (55 Gallon) FSH A 124.99 KH81 Wild Bird Food (25 Ib) 24 BRD 19.99 LD14 Locking Small Dog Door 14 DOG A 49.99 LP73 Large Pet Carrier 23 DOG B 59.99

Jun 10, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here