Add query='SELECT' back

Needed for aggregate queries to fix tests
The query includes ( ) parens

The ILIKE OR query creates a SQL statement with parens
around the multiple things being OR'd together.
Update the test to match this.
Fix typo: min > max

This is actually the max test case, not the min test case
Add test cases for count

Make sure we're generating the expected SQL