mardi 26 mai 2015

Creating new instance of subquery with sqlite

Suppose I have the following columns among three tables

Movie

mID | title | year | director 

Reviewer

rID | name

Rating

rID | mID | stars | ratingDate

The instructions that I have been given are:

"For all cases where the same reviewer rated the same movie twice and gave it a higher rating the second time, return the reviewer's name and the title of the movie"

The way I have approached this so far is I have done a three way merge of all the tables to capture all the needed information. What I wanted to do next is create an new instance of this three way merge and find where reviewer and movie are equal and where rating is higher. This is what I have so far

SELECT * 
FROM (SELECT *
FROM Movie Mov
INNER JOIN Rating Rat
   ON Mov.mID = Rat.mID
INNER JOIN Reviewer REv
   ON Rev.rID = Rat.rID) A, A table;
WHERE ...

The problem is that I am not able to create a new instance of A. Here I am attempting to do this here A table.

If anyone has any other suggestions on how to better approach this problem that is more clear please let me know.

Aucun commentaire:

Enregistrer un commentaire