What's wrong with my SQL code? It doesn't run. The SQL files are in the images attached. Queries should extract the answers directly. Use TopBabyNamesbyState.csv1 and write queries to extract the following information: # Which name in which state and in which year had the highest number of occurrences. # SELECT TopName, state, year from TopBabyNamesbyState where occurences=(select max(occurrences) from TopBabyNamesbyState); # What is the average occurrence of “Jessica” as a top name in the state of CA? # SELECT avg(occurrences) FROM TopBabyNamesbyState WHERE TopName='Jessica' and state='CA' Group by occurrences, state; # The three most popular female names in WA state since 2000. Popularity is based on the total number of occurrences. Report the names along with the total number of occurrences. # SELECT topname AS Name, Occurrence FROM TopBabyNamesbyState where year>=2000 and state='WA' and gender='F' ORDER BY Occurrence DESC limit 3; # Make a list of names that have an average occurrence greater than 1000. Order the result table by name in an ascending alphabetical order. # SELECT topname AS Name, avg(Occurrence) FROM TopBabyNamesbyState Group by topname having avg(Occurrence)>1000 order by topname ASC;
What's wrong with my SQL code? It doesn't run. The SQL files are in the images attached. Queries should extract the answers directly.
Use TopBabyNamesbyState.csv1 and write queries to extract the following information:
# Which name in which state and in which year had the highest number of occurrences. #
SELECT TopName, state, year from TopBabyNamesbyState
where occurences=(select max(occurrences) from TopBabyNamesbyState);
# What is the average occurrence of “Jessica” as a top name in the state of CA? #
SELECT avg(occurrences)
FROM TopBabyNamesbyState
WHERE TopName='Jessica' and state='CA'
Group by occurrences, state;
# The three most popular female names in WA state since 2000. Popularity is based on the total number of occurrences. Report the names along with the total number of occurrences. #
SELECT topname AS Name, Occurrence
FROM TopBabyNamesbyState where year>=2000 and state='WA' and gender='F'
ORDER BY
Occurrence DESC
limit 3;
# Make a list of names that have an average occurrence greater than 1000. Order the result table by name in an ascending alphabetical order. #
SELECT topname AS Name, avg(Occurrence)
FROM TopBabyNamesbyState
Group by topname
having avg(Occurrence)>1000
order by topname ASC;



Trending now
This is a popular solution!
Step by step
Solved in 2 steps









