So I have items that have different properties: tags(many to many), user feedback(many to many), price etc. and I'm trying to build the queries for filtering the results based on those properties.
Filtering on those properties doesn't seem to be a problem, I can just use joins and predicates.
The real problem is when I try to get aggregate data based on that query. Let's say I want to count how many of the current results also have a certain tag associated with it. I can't/don't know how to make a selection on the objects that a join is associating, it says it needs a root. I tried to add a new root in my original query but I don't know how to link it with my other root/roots.
Example of what I want. Db has two tables, items (that are toys) and tags (plushy, can speak). Step 1: You're not shown any result, but you're shown the tags and how many items are associated with those tags. Step 2: You select plushy tag and the result is returned, "can speak" tag will now return a different number of how many items are associated with that tag, because it takes into consideration only the items that are returned in the current result.
How do I do this?
|