What is the SQL command to count values in attribute "EYE COLOR" that holds total count in a derived column “EYE COLOR MOSTER TOTAL" of table "MONSTERS" who's "EVIL POWER" is "Glamouring". List the
What is the SQL command to count values in attribute "EYE COLOR" that holds total count in a derived column “EYE COLOR MOSTER TOTAL" of table "MONSTERS" who's "EVIL POWER" is "Glamouring". List the
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
Related questions
Question
100%

Transcribed Image Text:### SQL Exercise Example: Counting Eye Colors in Monsters Table
#### Objective:
To determine the SQL command needed to count values in the attribute "EYE_COLOR" and place this count in a derived column named "EYE_COLOR_MONSTER_TOTAL" from the table "MONSTERS", specifically for monsters whose "EVIL_POWER" is "Glamouring". The results should list the different eye colors and the number of monsters for each color, but only display colors if the count of monsters with that eye color is greater than 5.
#### Instructions:
Drag the appropriate SQL keywords and phrases to the provided blanks to complete the SQL statement.
#### SQL Statement Construction:
1. **SELECT** - The keyword used to specify that columns should be returned from the database.
2. **EYE_COLOR** - The attribute that we want to count values for.
3. **COUNT(EYE_COLOR)** - The function to count occurrences of each eye color.
4. **AS EYE_COLOR_MONSTER_TOTAL** - Assigning a name to our derived column that holds the count.
5. **FROM MONSTERS** - Indicates the table we are querying data from.
6. **WHERE EVIL_POWER = 'Glamouring'** - Filtering the rows to include only those monsters whose "EVIL_POWER" is "Glamouring".
7. **GROUP BY EYE_COLOR** - Grouping the results based on "EYE_COLOR".
8. **HAVING COUNT(EYE_COLOR) > 5** - Filtering the grouped results to only include those groups where the count is greater than 5.
9. **ORDER BY SKIN_COLOR DESC** - Optional ordering of the results based on another attribute, such as "SKIN_COLOR".
#### Complete SQL Statement:
```sql
SELECT
EYE_COLOR,
COUNT(EYE_COLOR) AS EYE_COLOR_MONSTER_TOTAL
FROM
MONSTERS
WHERE
EVIL_POWER = 'Glamouring'
GROUP BY
EYE_COLOR
HAVING
COUNT(EYE_COLOR) > 5
ORDER BY
SKIN_COLOR DESC;
```
This SQL query effectively retrieves the count of monsters with each eye color that have "Glamouring" as their "EVIL_POWER", but only for those eye colors that appear more than 5 times. The results are further ordered by the "SKIN_COLOR" attribute in descending order for additional sorting.
##### Drop-down Options Provided:
-
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images

Knowledge Booster
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.Recommended textbooks for you

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)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON

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)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON

C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON

Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning

Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education