Friday, June 25, 2010

Sample Code for Generating FIs

Here is the sample code to generate the name of FIs and the number of the households they have interviewed.

SELECT DISTINCT s.enumeratorlastname LastName, s.enumeratorfirstname FirstName, COUNT(*) as Surveyed,pl.locationname Municipality
FROM survey s, household h, location l, location ll, location pl, surveydate sd
WHERE s.householdid = h.householdid AND h.locationid = l.locationid
AND ll.locationid = l.parentid AND pl.locationid = ll.parentid AND s.surveydateid = s.surveydateid
AND pl.locationname = "Sagbayan" AND sd.surveyyear = 2004
GROUP BY LastName, FirstName
ORDER BY LastName, FirstName;

No comments:

Post a Comment