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;
![A
Bi
10466 WY
M
1971 Michael
137
10467 WY
M
1972 Michael
113
10468 WY
M
1973 Michael
119
10469 WY
M
1974 Jason
127
10470 WY
M
1975 Michael
131
10471 WY
M
1976 Jason
125
10472 WY
M
1977 Michael
137
10473 WY
M
1978 Michael
145
10474 WY
M
1979 Michael
155
10475 WY
M
1980 Michael
174
10476 WY
M
1981 Joshua
160
10477 WY
M
1982 Michael
161
10478 WY
M
1983 Michael
171
10479 WY
M
1984 Michael
144
10480 WY
M
1985 Christopher
142
10481 WY
M
1986 Christopher
125
10482 WY
M
1987 Michael
94
10483 WY
M
1988 Michael
99
10484 WY
M
1989 Michael
102
10485 WY
M
1990 Michael
83
10486 WY
M
1991 Michael
85
10487 WY
M
1992 Michael
74
10488 WY
M
1993 Tyler
90
10489 WY
M
1994 Austin
71
10490 WY
M
1995 Joshua
62
10491 WY
1996 Tyler
M
68
10492 WY
M
1997 Jacob
55
10493 WY
M
1998 Austin
55
10494 WY
M
1999 Michael
52
10495 WY
M
2000 Jacob
49
10496 WY
M
2001 Jacob
44
10497 WY
M
2002 Ethan
52
10498 WY
M
2003 Jacob
47
10499 WY
M
2004 Michael
34
10500 WY
M
2005 Jacob
41
10501 WY
M
2006 Ethan
44
10502 WY
2007 James
38
10503 WY
M
2008 James
41
10504 WY
M
2009 Wyatt
42
10505 WY
M
2010 James
36
10506 WY
M
2011 William
32
10507 WY
M
2012 Liam
41](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Fe8b72512-0a51-4568-8fb3-5ec320d71f77%2F336e1147-4a16-44cc-9a35-4c27ccfebde6%2Fod7y2ji_processed.png&w=3840&q=75)
![A.
Bi
State
Gender
Year
TopName
Occurrences
AK
F
1910 Mary
14
3
1911 Mary
AK
F
12
AK
F
1912 Mary
5
AK
F
1913 Mary
21
AK
F
1914 Mary
22
7
1915 Mary
AK
F
23
AK
F
1916 Mary
18
9
AK
1917 Mary
21
10
AK
1918 Mary
F
27
11
AK
F
1919 Mary
22
12
AK
F
1920 Mary
38
13
1921 Mary
AK
F
36
14
1922 Mary
AK
F
29
15
AK
1923 Mary
26
16
AK
F
1924 Mary
41
17
AK
F
1925 Mary
24
18
AK
F
1926 Mary
39
19
1927 Mary
AK
F
30
20
AK
F
1928 Mary
27
21
AK
1929 Mary
25
22
AK
F
1930 Mary
35
23
AK
F
1931 Mary
41
24
1932 Mary
AK
F
26
25
AK
F
1933 Mary
25
26
AK
F
1934 Mary
31
27
AK
F
1935 Mary
29
28
AK
F
1936 Mary
33
29
AK
1937 Mary
41
30
AK
F
1938 Mary
37
31
AK
F
1939 Mary
28
32
AK
F
1940 Mary
43
33
AK
F
1941 Mary
40
34
AK
F
1942 Mary
43
35
AK
1943 Mary
47
36
AK
F
1944 Mary
42
37
AK
F
1945 Mary
47
38
AK
F
1946 Mary
47
39
AK
F
1947 Mary
63
40
1948 Mary
AK
F
71
41
AK
1949 Mary
79
42
AK
F
1950 Mary
71
9.
2.](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Fe8b72512-0a51-4568-8fb3-5ec320d71f77%2F336e1147-4a16-44cc-9a35-4c27ccfebde6%2Fderqfso_processed.png&w=3840&q=75)
![](/static/compass_v2/shared-icons/check-mark.png)
Trending now
This is a popular solution!
Step by step
Solved in 2 steps
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![C How to Program (8th Edition)](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
![Database Systems: Design, Implementation, & Manag…](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
![Programmable Logic Controllers](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)