Yes, this is a smal portion of the whole query i use, i retrieve more columns and i do not want to group by all of them.
i did notice this only when we got more than 100k records and the query became very slow. The trick here that subquery is used to do filtering, it is not fixed SQL statement it may contain more conditions.
It seems i need to figure out different method of doing this.
thanks