### Description of my problem (somewhat simplified)

I have two datasets:

* One polygon layer "villages" which represents the boundary of villages
* One point layer "buildings" which represent buildings. This layer has the attributes "year of construction" and "type".

I would like to count the number of buildings (points) inside each village (polygone) which are of a given type and age, namely:

* Number of individual houses with year of construction < 2000
* Number of individual houses with year of construction > 2000
* Number of appartment buildings with year of construction < 2000
* Number of appartment buildings with year of construction > 2000

The following figure shows an example, with the blue polygon representing the village and each point a building, with styling applied to distinguish the 4 categories of buildings mentionned above (purple: buildings <2000; green: buildings >2000; triangles: individual houses; squares: appartment buildings):

[![](https://i.stack.imgur.com/XyYT4.png)](https://i.stack.imgur.com/XyYT4.png)

I know how to count points within a polygon using "Analysis Tools" in the "Processing framework" plugin, but I do not how to count only the points which respect a given rule.

Any suggestions?