Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7697293
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T21:58:42+00:00 2026-05-31T21:58:42+00:00

Have been working on this question for a couple hours and have come close

  • 0

Have been working on this question for a couple hours and have come close but still can’t get the results I am wanting. Here is the question below:

For all movies that have an average rating of 4 stars or higher, add
25 to the release year. (Update the existing Rows; don’t insert new
Rows.) .

The tables required for this query are in another question I have already posted on here, at How to get results of this particular "query". The table names are “movie” and “rating”. You can see some sql code there as well if it will help.

The first step I took to solve this problem was to (obviously) look for the movies that have an average rating of 4 stars or higher. I did that with the following query:

SELECT movie.mid, aveMovieRating 
FROM movie JOIN(
    SELECT DISTINCT(rating.mid), 
    COUNT(mid) AS "Number of movies", 
    SUM(stars) AS "Total no# of stars", 
    (SUM(stars)*1.0/COUNT(mid)) AS aveMovieRating
    FROM rating 
    GROUP BY mid
) AS aveRating
ON movie.mid = aveRating.mid
WHERE aveMovieRating >= 4

Then I came to the tricky part – trying to alter the release year, as per question requirements… This is the query I came up with for attempting that:

UPDATE movie
SET year = (year + 25)
WHERE movie.mid IN(
SELECT movie.mid, aveMovieRating 
FROM movie JOIN(
    SELECT DISTINCT(rating.mid), 
    COUNT(mid) AS "Number of movies", 
    SUM(stars) AS "Total no# of stars", 
    (SUM(stars)*1.0/COUNT(mid)) AS aveMovieRating
    FROM rating 
    GROUP BY mid
) AS aveRating
ON movie.mid = aveRating.mid
WHERE aveMovieRating >= 4)

Executing the above query generates the following SQL error in SQLite:

Error: only a single result allowed for a SELECT that is part of an expression

This was my first attempt at a “complicated” question without getting outside help, but this error threw me off. If someone is able to help me alter the above query, and give some pointers about this type of problem, that would be awesome :).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T21:58:43+00:00Added an answer on May 31, 2026 at 9:58 pm

    Remove aveMovieRating from select list. The error says that clearly: “only a SINGLE RESULT allowed for…”. IN operator works on a set of single column rows.

    UPDATE:

    As for update, you can compact it a bit by removing unnecessary columns:

    UPDATE movie
    SET year = (year + 25)
    WHERE movie.mid IN (
            SELECT rating.mid
            FROM rating 
            GROUP BY mid
            HAVING avg(Stars) >= 4
    )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been working on this for days but I don't get it so
I have been working on this for 24 hours now, trying to optimize it.
i have been working on this sub-menu for 8 hours now, the last little
I have been working on this for the greater part of the day and
I have been working on this problem for 2 days now and it's an
I have been working on this problem for a while now. I am trying
I have been working on this for some time now and just cant quite
I have been working on this for some time. The script does work and
So I have been working on this project for a short while now. I
**Updated: (See below)**I have been looking around for couple of days and can't find

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.