-implement record group and having query
- add some comments