in WebRatio 6.1 you can define the Aggregate/Imported Attributes
directly on the unit. You can see an example in the WebRatio Release Notes (Help > WebRatio Release Notes)
If you prefer write and execute a custom query, you can add a Query Unit to your model. For more details you can read this article:
Getting started with the Query Unit
There is another way, in fact you can refer to this article of our wiki:
The derivation in the data model
In this case you can use a Calculated Attribute.