SQL QUESTIONEASY Need to write a single SQL query for each o

SQL QUESTION!!EASY!

Need to write a single SQL query for each of the question. ERD diagram is up there.

What are the most common character names and how many times do they show up?

SELECT....

Solution

This can be done with a very simple sql statement where we find the most occuring/repeated element in the column of a sql table. The query will be:

SELECT name,
COUNT(name) AS most_name
FROM char_name
GROUP BY char_name
ORDER BY most_name DESC
LIMIT 1;

Here we are selecting the name and the count of the most occuring name from the character name table and based on the highest value in the column we are displaying the count and name of the character in the char_name table.

SQL QUESTION!!EASY! Need to write a single SQL query for each of the question. ERD diagram is up there. What are the most common character names and how many ti

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site