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. My instructor gave 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 ________________;

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

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.

My instructor gave 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
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
Transcribed Image 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
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY