Trying to run the following HQL with NHibernate:
select count(distinct t) as TweetCount
from Tweet t
join t.Tweeter u
left join t.Votes v
left join t.Tags tag
where t.App = :app
having count(distinct v) > 0
But for some reason the having clause is being ignored and it's counting all tweets when only 2 tweets have a vote. I basically want to count the number of Tweets that have at least one Vote.
Here is my database
I tried adding a group by to my query like so:
select count(distinct t) as TweetCount
from Tweet t
join t.Tweeter u
left join t.Votes v
left join t.Tags tag
where t.App = :app
group by t
having count(distinct v) > 0
...but it ended up returning a collection containing 2 integers each set to '1' instead of a unique result.