chiark / gitweb /
list people who had children at given age; good for finding errors
[familyTree.git] / familyTree / askQuestion.py
index f5cfa244551164a44f69d6fcb43f45fcb4332fda..6e9642635213f84bc4ac330d7f71103bdaadd63f 100755 (executable)
@@ -271,6 +271,28 @@ def count_age_at_child(newLine):
        out = print_query(s,(),newLine)
        return out
 
+def people_had_child_at_age(age,newLine):
+
+       s = "select p1.bornYear - p2.bornYear as age, p1.name, p1.ID"\
+                +",p2.name,p2.ID FROM"\
+                +" parents INNER JOIN people p1"\
+                +" ON parents.ID = p1.ID"\
+                +" INNER JOIN people p2"\
+                +" ON parents.parentID = p2.ID"\
+               +" WHERE age = ?"
+
+       t = (int(age),)
+
+       out = ''
+       out = 'At age ' + str(age) + ' :'
+       for row in run_query(s,t):
+               out = out + newLine
+               out =out + name_html([row[3],row[4]],newLine) + ' had '\
+                       +name_html([row[1],row[2]],newLine)
+
+       return out
+
+
 def all_ancestors(personID,newLine):
        #find parents
         s = "SELECT people.Name,parents.parentID FROM"\