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 ________________;

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
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.

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
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
Knowledge Booster
SQL Functions
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education