retrieve the premium users that take the course courseId and got a mark higher or equal to minScore and strictly lower than maxScore
SELECT p.userid, s.score FROM premium p, subscription s WHERE p.userid = s.userid AND
DATE(p.startedat) <= DATE(s.signedat) AND DATE(p.endedat) >= DATE(s.endedat) AND s.score >= minScore AND s.score < maxScore AND s.courseId = courseId
return a list ((userId, score), ... (userId, score))
'''
idUsers=[]
try:
self.connection.text_factory=str
cursor=self.connection.cursor()
query=("SELECT p."+DatabaseManager.PREMIUM_COLUMN_USER_ID+", s."+DatabaseManager.SUBSCRIPTION_COLUMN_SCORE+" FROM "+DatabaseManager.TABLE_PREMIUM_NAME+" p, "+
DatabaseManager.TABLE_SUBSCRIPTION_NAME+" s WHERE p."+DatabaseManager.PREMIUM_COLUMN_USER_ID+" = s."+DatabaseManager.SUBSCRIPTION_COLUMN_USER_ID+" AND "+
"DATE(p."+DatabaseManager.PREMIUM_COLUMN_STARTED_AT+") <= DATE(s."+DatabaseManager.SUBSCRIPTION_COLUMN_SIGNED_AT+") AND DATE(p."+
DatabaseManager.PREMIUM_COLUMN_ENDED_AT+") >= DATE(s."+DatabaseManager.SUBSCRIPTION_COLUMN_ENDED_AT+") AND s."+
DatabaseManager.SUBSCRIPTION_COLUMN_SCORE+" >= "+str(minScore)+" AND "+DatabaseManager.SUBSCRIPTION_COLUMN_SCORE+" < "+str(maxScore)+" AND "+