Changeset - 9c927dc379bc
[Not reviewed]
default
0 1 0
Laman - 7 years ago 2018-03-27 13:40:25

populationAge query
1 file changed with 19 insertions and 2 deletions:
0 comments (0 inline, 0 general)
queries.py
Show inline comments
 
@@ -76,8 +76,24 @@ def populationStrength(year,country):
 
		print("\t".join([str(x) for x in rec]))
 

	
 

	
 
def populationAge():
 
	pass
 
def populationAge(year,country):
 
	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
 
			)
 
			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():
 
@@ -88,3 +104,4 @@ def tournamentAttendance():
 
# yearByCountry(2017)
 
# timeRank(2017,"CZ")
 
# populationStrength(2017,"CZ")
 
# populationAge(2017,"CZ")
0 comments (0 inline, 0 general)