Changeset - ed00726edba5
[Not reviewed]
default
0 1 0
Laman - 7 years ago 2018-04-01 13:59:11

fix populationAge pro hráče měnící země. 14586913 2006
1 file changed with 3 insertions and 3 deletions:
0 comments (0 inline, 0 general)
queries.py
Show inline comments
 
@@ -117,26 +117,26 @@ def populationStrength(year1,year2,count
 

	
 

	
 
def populationAge(year,country):
 
	"""Rozdělení populace země v daném roce podle doby hraní (celých let od prvního turnaje). Uvažují se pouze aktivní hráči."""
 
	date1=yearStart(year)
 
	date2=yearStart(year+1)
 
	query="""
 
		select date(?)-min_datum-1 as playing_years,count(pin)
 
			from (
 
				select ppt1.pin,min(ppt1.datum) as min_datum
 
					from players_performance_tournaments as ppt1
 
						join players_performance_tournaments as ppt2 on ppt1.pin=ppt2.pin
 
					where ppt2.datum>=date(?) and ppt2.datum<date(?) and ppt1.p_country_code=?
 
					group by ppt1.pin
 
					where ppt2.datum>=date(?) and ppt2.datum<date(?) and ppt2.p_country_code=?
 
					group by ppt2.pin
 
			)
 
			group by playing_years
 
	"""
 

	
 
	res=cursor.execute(query,(date2,date1,date2,country))
 
	print("celé roky hraní\tpočet hráčů")
 
	for rec in res:
 
		print("\t".join([str(x) for x in rec]))
 

	
 

	
 
def tournamentAttendance(year):
 
	"""Návštěvnosti turnajů za daný rok, dělené podle země konání."""
 
@@ -145,16 +145,16 @@ def tournamentAttendance(year):
 
	query="""select country_code,sum(player_count) from tournaments where datum>=date(?) and datum<date(?) group by country_code"""
 

	
 
	res=cursor.execute(query,(date1,date2))
 
	print("kód země\tpočet hráčů na turnajích")
 
	for rec in res:
 
		print("\t".join([str(x) for x in rec]))
 

	
 

	
 
# playerYear("Kotowski Jaroslav",2017)
 
# yearByCountry(2017)
 
# timeRank(2017,"CZ")
 
# populationStrength(2017,"CZ")
 
# populationAge(2017,"CZ")
 
# populationAge(2006,"CZ")
 
# tournamentAttendance(2010)
 
# yearsByCountry(2001,2018)
 
# populationStrength(2017,2018,"CZ")
0 comments (0 inline, 0 general)