# All invoices above a MinValue in a City and State select object() from Project::Invoice where lineitems.total.sum() > ?MinValue and billto.address.where(city = ?City and state = ?State) # All employees who were paid less than the value of the # projects for which they worked. select object() from Foo::Employee where salary > parents(Foo::Project, employees).billings.lineitems.sum() # All contacts whose first and second alternates are in # State and whose fax starts with AreaCode # or have referred N jobs about Value in dollars select object() from Bar::Contact where alternates[0..1].address.state = ?State and numbers{fax} like concat(?AreaCode, '%') or refferals.jobs.where(count() >= ?N and billings.lineitems.total.sum() >= ?Value) is not empty