# HG changeset patch # User Laman # Date 2018-05-04 12:34:57 # Node ID 8732ad224e56c33e8be411df2fc52420adc6c440 # Parent 071f264dfb0cd5372d6d2b3670f294d8d73fbe78 dotaz fetchByRating diff --git a/queries.py b/queries.py --- a/queries.py +++ b/queries.py @@ -180,9 +180,21 @@ def tournamentAttendance(year1,year2): print(country,end="\t") print("\t".join(str(res[country].get(y,0)) for y in range(year1,year2))) + +def fetchByRating(strongerThan,country=""): + """Hráči, kteří dosáhli rating strongerThan nebo vyšší, nepovinně filtrovaní podle země, seřazení od nejlepšího dosaženého ratingu.""" + query="""select pin,name,max(rating_after) as max_rating from players_performance natural join players where rating_after>=? and (?='' or country_code=?) group by pin order by max_rating desc""" + + res=cursor.execute(query,(strongerThan,country,country)) + print("pin\tjméno\tmax rating") + for rec in res: + print("\t".join([str(x) for x in rec])) + + # playerYear("Kotowski Jaroslav",2017) # timeRank(2017,"CZ") # yearsByCountry(2001,2018) # populationStrength(2001,2018,"RU") # populationAge(2001,2018,"RU") # tournamentAttendance(2001,2018) +# fetchByRating(2600,"CZ")