Adding having functionality and tests

I needed to have a query with having, so I implemented it =)