Thanks very much! Unfortunately this seems to count all instances of MobileProvider. I'm trying to count only the last instance of StateInfo.MobileProvider.
Here is the exact query I tried:
Code:
select count(ID) from Asset as asset join asset.StateInfo si where si.MobileProvider.Name='Vodafone'
As you may recall I'm trying to count the number of instances where the last member/entry of Asset.StateInfo.MobileProvider.Name equals a given string. Here's a breakdown of the references
Asset--[one-to-many]-->StateInfo--[one-to-one]-->MobileProvider
Somebody else suggested using "elements" as such
Code:
select count(asset.ID) from Asset as asset, MobileProvider as mp where mp in elements(asset.StateInfo) and
mp.Name='Vodafone'
Unfortunately this appears to return the count of MobileProvider rows instead of the number of asset's that reference MobileProvider in the last member of StateInfo.
Any other suggestions would be greatly appreciated!
nordborg wrote:
You'll need to use a join:
Code:
...from Asset as asset join asset.StateInfo si where si.MobileProvider.....