Skip to main content
added 70 characters in body
Source Link
Laurenz Albe
  • 56.4k
  • 4
  • 49
  • 82

A small change: report for each year the percentage of movies in that year with only female actors, and the total number of movies made that year.

SELECT Year,
       COUNT(*),
       (COUNT(*)*100/(count(Movie.mid)*1.0))   
FROM Movie  
WHERE TRIM(MID) IN (SELECT TRIM(MID)
                    FROM M_Cast
           (SELECT TRIM(MID)  FROM M_Cast     WHERE TRIM(PID) IN (SELECT TRIM(PID)
                                        FROM PERSON
   (SELECT TRIM(PID) FROM PERSON WHERE Gender ='Female'))
                               WHERE Gender ='Female'
           GROUP BY Movie.Year
                          )
                   )
GROUP BY Movie.Year
ORDER BY COUNT(*) DESC

What should I change in this to get correct percentage What should I change in this to get the correct percentage?

A small change: report for each year the percentage of movies in that year with only female actors, and the total number of movies made that year.

SELECT Year,COUNT(*),(COUNT(*)*100/(count(Movie.mid)*1.0))  FROM Movie WHERE TRIM(MID) IN
                                (SELECT TRIM(MID)  FROM M_Cast WHERE TRIM(PID) IN 
                                            (SELECT TRIM(PID) FROM PERSON WHERE Gender ='Female'))
                                            GROUP BY Movie.Year
                                            ORDER BY COUNT(*) DESC

What should I change in this to get correct percentage

A small change: report for each year the percentage of movies in that year with only female actors, and the total number of movies made that year.

SELECT Year,
       COUNT(*),
       (COUNT(*)*100/(count(Movie.mid)*1.0)) 
FROM Movie 
WHERE TRIM(MID) IN (SELECT TRIM(MID)
                    FROM M_Cast
                    WHERE TRIM(PID) IN (SELECT TRIM(PID)
                                        FROM PERSON
                                        WHERE Gender ='Female'
                                       )
                   )
GROUP BY Movie.Year
ORDER BY COUNT(*) DESC

What should I change in this to get the correct percentage?

Source Link

How to get for a percentage here in below query?

A small change: report for each year the percentage of movies in that year with only female actors, and the total number of movies made that year.

SELECT Year,COUNT(*),(COUNT(*)*100/(count(Movie.mid)*1.0))  FROM Movie WHERE TRIM(MID) IN
                                (SELECT TRIM(MID)  FROM M_Cast WHERE TRIM(PID) IN 
                                            (SELECT TRIM(PID) FROM PERSON WHERE Gender ='Female'))
                                            GROUP BY Movie.Year
                                            ORDER BY COUNT(*) DESC

What should I change in this to get correct percentage