Questions tagged [pset7]

For problem set 7 (CS50 Finance)

Filter by
Sorted by
Tagged with
0 votes
0 answers
29 views

PSET7 Movies - SQL.13 , how come I have to use the same JOIN lines again? Aren't the tables already joined?

SELECT name FROM people JOIN stars ON stars.person_id = people.id JOIN movies on stars.movie_id = movies.id WHERE movies.id = (SELECT movies.id WHERE stars.person_id = (SELECT id FROM people WHERE ...
user avatar
0 votes
0 answers
21 views

What's wrong in this query?

Why this query outputs just 61 rows instead of more than 185? I 'm trying to do 13.sql SELECT name FROM people WHERE id = (SELECT person_id FROM STARS JOIN people ON people.id = stars.person_id WHERE ...
user avatar
0 votes
0 answers
60 views

11.sql Why my SQL SELECT query changes order?

When i execute this query: SELECT movie_id FROM ratings WHERE movie_id IN ( SELECT movie_id FROM stars WHERE person_id IN ( SELECT id FROM people WHERE name='...
user avatar
0 votes
1 answer
31 views

PSET7/SQL Any clues as to why my logic isn't working? (13.sql)

This very nested query is to return names of all the actors that performed on a Kevin Bacon film. Instead it's returning nothing, any ideas are appreciated! Note: I'm yet to implement the part that ...
user avatar
0 votes
1 answer
708 views

Fiftyville - please help!

I am quite sure about my answers... but still, check50 doesn't approve my answers... can you please tell me whether my answers are indeed wrong to start thinking about it again cause in my mind I am ...
user avatar
0 votes
1 answer
95 views

SQL QUERY MOVIES.DB

I have written the query for 6.sql but it does not work. SELECT AVG(rating) FROM ratings WHERE movie_id = (SELECT id FROM movies WHERE year = 2012); I can do this by using JOIN SELECT AVG(rating) ...
user avatar
  • 72
0 votes
1 answer
78 views

How does the database ER diagram look like in Pset7 (Fiftyville)?

Pset7 (Fiftyville) DB has 10 tables. It would be much easier to work with them if the entity–relationship model (ER diagram) is presented. Pset description doesn’t have it.
user avatar
0 votes
1 answer
537 views

Pset 7 Fiftyville

I am quite sure about my answers but check50 keeps saying its incorrect. Im not sure if I am giving the answers in the correct way. For ex. The thief escaped to Heathrow(I think)/ London but I am not ...
user avatar
  • 7
0 votes
2 answers
519 views

Fiftyville: Can't find a logical way to find the thief

I have done the appropriate INTERSECTION between the person at the: atm, exiting the parking lot and the person on the first flight out of Fiftyville on the 29th. I am left with two people. I know who ...
user avatar
  • 1
0 votes
1 answer
87 views

pset7/fiftyville - Some people do not have a passport number

I ran the following query SELECT name, passport_number FROM people ORDER BY name; This was the result name | passport_number Aaron | 9852889341 Abigail | Adam | Alan | 2884243902 Albert | ...
user avatar
0 votes
1 answer
37 views

pset7 - buying and selling from index results in duplicate flash's and apologies not being rendered

I passed all the check50 tests and I am working on my personal touch component, which for me is adding buying and selling to index. Everything works except: When more than one stock is sold/bought, ...
user avatar
0 votes
1 answer
589 views

pset7 Fifty Ville // not sure how to get the intersect of cases to find the thief

I am currently doing pset7 and I have found most of the clues of who it is but the problem is that I need to use the intersect sql function to find the common name of the thief but I am not sure how. ...
user avatar
  • 17
0 votes
1 answer
76 views

DIFFERENCE BETWEEN TWO SQL CODES

I wrote these two codes for SQL pset7 but I'm getting different answers. Can anybody tell me the cause of the difference? SELECT COUNT(title) FROM movies WHERE id = (SELECT movie_id FROM ratings WHERE ...
user avatar
0 votes
2 answers
2k views

pset7 movies sql7

I'm doing the pset8 tasks. Currently, I have some issues with sql7. In 7.sql, write a SQL query to list all movies released in 2010 and their ratings, in descending order by rating. For movies with ...
user avatar
0 votes
1 answer
70 views

pset 7 houses passes check 50 but shows the names 4 times

I have a really strange problem here: both import and rooster passes every check in check 50, but if I run Rooster the names on every house appear 4 times. I have no clue about why this is happening, ...
user avatar
0 votes
1 answer
57 views

Pset 7 Houses: Import seems to work but check50 doesn´t agree

I am confuse with this one: The program doesn´t return any error when I run it and if I go to the students table the names are there, but check50 says it imports "[]". Am I at least close to ...
user avatar
0 votes
3 answers
170 views

accidentally imported data multiple times (pset7 houses)

I was testing the code out and ended up running "python import.py characters.csv" multiple times. Now when I go into sqlite3 and print out the data it's repeated itself 3 times over, once ...
user avatar
2 votes
0 answers
56 views

Students only passing 4/6 the last two showing concatnation error but works locally somebody help

[33mTraceback (most recent call last):[0m [33mFile "roster.py", line 34, in main()[0m [33mFile "roster.py", line 27, in main print(row[0] + " " + row[1]+" "+ ...
user avatar
0 votes
1 answer
54 views

In students its printing all the data correctly but when I try to insert it into db its showing this funny error

File "import.py", line 58, in db.execute("INSERT INTO students (first, middle, last, house, birth) VALUES (name[0], NULL, name[1],house, birth)") File "/usr/local/lib/python3....
user avatar
0 votes
2 answers
144 views

How can I check my number of rows on pset7 movies?

I wanted to check my queries one by one as I am doing them, my 1.sql works fine but how I find out how many rows I am getting?
user avatar
0 votes
1 answer
121 views

PSET7 7.sql Error

The code gives the right amount of rows but is not passing the check50 SELECT movies.title, ratings.rating FROM movies JOIN ratings ON ratings.movie_id = movies.id WHERE year = 2010 ORDER BY title ASC
user avatar
0 votes
2 answers
304 views

pset7 6.sql rounding problem

My code works fine but check50 give me an error because it´s not rounded the same way. :( 6.sql produces correct result expected "7.74", not "7.75" SELECT ROUND(AVG(rating), 2) ...
user avatar
0 votes
1 answer
31 views

7.sql CASE error

I'm getting an error where it says Error: near line 3: near "DESC": syntax error My code is SELECT title, rating FROM movies JOIN ratings ON movies.id = ratings.movie_id WHERE year = 2010 ...
user avatar
  • 11
0 votes
1 answer
70 views

PSET 7, failing on Luna Lovegood test case even though output looks the same as expected output

Expected Output [{'first': 'Luna', 'middle': None, 'last': 'Lovegood', 'house': 'Ravenclaw', 'birth': 1981}] Actual Output: [{'first': 'Luna', 'middle': 'None', 'last': 'Lovegood', 'house': 'Ravenclaw'...
user avatar
1 vote
1 answer
104 views

Submit50 for pset7 movies loads SQL files but returns "Error when executing query: missing statement"

When I execute: submit50 cs50/problems/2020/x/movies All my SQL files are sent for grading and all come back with the same error: Error when executing query: missing statement I have tried the sql ...
user avatar
0 votes
1 answer
677 views

PSET 7 Movies SQL Q9

In 9.sql, write a SQL query to list the names of all people who starred in a movie released in 2004, ordered by birth year. ...Your query should output a table with a single column for the name of ...
user avatar
0 votes
1 answer
20 views

Why updating a dictionary is not working?

for row in rowsList: if row['middle'] is None: row['middle'] == "" print("{} {} {}, born {}".format(row['first'], row['middle'], row['last'], row['birth'])) Where ...
user avatar
  • 105
0 votes
1 answer
68 views

PSET 7 HOUSES - Syntax error on case function

I'm trying to select the first name and last name and ONLY select the middle name when there is one. The logic of my query makes sense. Every time I am extracting the first name, last name, and birth. ...
user avatar
  • 5
0 votes
1 answer
60 views

When I run the testing code, it says that movies.db does not exist. How should I fix it?

This is my code in the terminal: cat 1.sql | sqlite3 movies.db This is the output: Error: near line 1: no such table: movies.db
user avatar
1 vote
1 answer
156 views

CS50 Houses : Output is correct in my console but error in check50

I am working on the CS50 course by Harvard EDx. The output for CS50 - Houses is correct in my console. However, check50 which is validates and evaluates the response gives an error. I have checked the ...
user avatar
0 votes
1 answer
78 views

Pset7 houses - why does my output prints thrice instead of once?

The code is as follows: for row in students_list: first, middle, last, birth = row["first"], row["middle"], row["last"], row["birth"] print(f"{...
user avatar
0 votes
1 answer
296 views

pset7 Q10 Weird Result

The challenge is apparently straightforward: write an SQL query to list the names of all people who have directed a movie that received a rating of at least 9.0. To get from names (which lives in the '...
user avatar
0 votes
2 answers
406 views

PSET 7 movies 5.sql check50 not giving the actual output correctly

the check50 output doesn't match sqlite3 output. the code runs and outputs 10 rows in sqlite3 and DBsqlite but check50 output is different.
user avatar
0 votes
1 answer
101 views

How to exclude 'Kevin Bacon's' name from query table?

i have tried to exclude the name from the list but most of the solution aren't doing anything. anyone have idea how to solve. SELECT name FROM movies JOIN stars ON movies.id=stars.movie_id JOIN ...
user avatar
0 votes
1 answer
252 views

Pset7 (Movies) 12.sql: Table outputs 96 rows rather than 5 rows

I've been stuck on this for quite some time and did a lot of research on the AND operator in SQL, but no matter how many variations I try I cannot get my table to output just 6 rows, with each row ...
user avatar
0 votes
1 answer
476 views

PSET 7 Movies 12.sql

can someone explain the difference between using IN and "="? Here is my code. When I use IN it runs perfectly but when I use "=" there is no output. Thank you! SELECT title FROM ...
user avatar
  • 1
0 votes
1 answer
222 views

PSET 7 - 6.sql, terminal just hangs

PSET 7 for 6.sql, Terminal just hangs when I execute it. Can anyone tell me why this wouldn't work? I've tried every variation I could think of (and several I found online) for this and none of them ...
user avatar
0 votes
1 answer
60 views

pset7 houses printing the error message if wrong usage

The commandline argument check in roster.py: A bit strange, I find whatever I am doing I can't get this error message to print, the function will shut down alright, but no error message, I have tried ...
user avatar
0 votes
1 answer
130 views

Pset7 Movies Q12: I don't get what's wrong

I can't figure out why my pset7 movies Q12 code isn't working. Can anyone tell me why? Here is my code: SELECT DISTINCT title FROM movies, stars, people WHERE movie_id IN (SELECT movie_id FROM stars ...
user avatar
  • 1
0 votes
1 answer
502 views

Misuse of aggregate function CS50 Pset 7 10.sql

I'm stuck on pset7 10.sql, it keeps coming up with a misuse of aggregate function. My code is currently: SELECT name FROM people INNER JOIN directors ON people.id = directors.person_id INNER JOIN ...
user avatar
0 votes
1 answer
179 views

CHECK50 Bug in pset7: movies SQL

I have been banging my head on this for an hour and half. Finally finished the pset, uploaded it. Check 50 says: Now, both cs50 ide and DB browser return the correct results, and number of lines for ...
user avatar
0 votes
1 answer
283 views

Houses ~ Import.py - Nothing being inserted into students.db

The following is my code: import csv from sys import argv import sqlite3 import os.path def main(): #Check if correct number of arguments were provided by the user if len(argv) != 2: ...
user avatar
0 votes
1 answer
346 views

pset7 Q7: How many actors are named "Meryl"?

I am at a complete loss for something that should be very simple to find in SQLite. In the IMDB database, I have to find how many actors have the name 'Meryl', I have tried select name, count(name) ...
user avatar
0 votes
1 answer
204 views

pset7 Houses get 17% submit

My code run right and My output same they output but after submitted get 17% why //import.py from sys import argv, exit import cs50 import csv if len(argv) != 2: print("...
user avatar
0 votes
1 answer
45 views

I am working through roster.py, but the first line in the solution is not printing in my output. why is this happening?

import cs50 import sys import sqlite3 db = sqlite3.connect("students.db") house_reader = db.cursor() if len(sys.argv) != 2: print('Usage: import.py file.csv') exit() house_reader.execute("...
user avatar
0 votes
1 answer
318 views

PSET7 Movies Q8 - Why these queries return different results?

I'm working on pset7 movies problem of the CS50 course and I have a question regarding 8.sql, which asks to write a SQL query to list the names of all people who starred in Toy Story. To my ...
user avatar
  • 3
0 votes
1 answer
417 views

Pset 7 Movies - 13.sql "Error When Executing Query - Too Many Statements at Once"

I'm working on Pset 7 "Movies" and check50 shows an error for 13.sql (list of Kevin Bacon's co-stars) when I submit my code despite running successfully in the IDE. The exact error message is Error ...
user avatar
  • 3
0 votes
0 answers
75 views

Pset7 buy route error due to API use by lookup function

I am experiencing an error each time I call the lookup function within the buy route when the request method equals post. However, calling lookup during quote does not result in the same error. I ...
user avatar
  • 1
0 votes
1 answer
82 views

Pset7 Houses, what does my error message mean?

Whenever I run my code, I get a strange error message because of my code. It is because of my SQL code, but I followed all of the instructions, and even tried some other SQL code, which worked ...
user avatar
  • 2
0 votes
1 answer
585 views

pset7/movies/13.sql: exclude Kevin Bacon from the resulting list

In pset7/movies, I want to dynamically exclude Kevin Bacon from the resulting list (e.g. not specifically mentioning his name with NOT or EXCEPT or copying and pasting code that calculates his ID, so ...
user avatar

1
2 3 4 5
15