Group specify the group method on the find // Select the sum age of users with given names db.Model(&User{}).Select("name, sum(age) as total").Group("name").Find(&results)
(name string)
| 281 | // // Select the sum age of users with given names |
| 282 | // db.Model(&User{}).Select("name, sum(age) as total").Group("name").Find(&results) |
| 283 | func (db *DB) Group(name string) (tx *DB) { |
| 284 | tx = db.getInstance() |
| 285 | |
| 286 | fields := strings.FieldsFunc(name, utils.IsInvalidDBNameChar) |
| 287 | tx.Statement.AddClause(clause.GroupBy{ |
| 288 | Columns: []clause.Column{{Name: name, Raw: len(fields) != 1}}, |
| 289 | }) |
| 290 | return |
| 291 | } |
| 292 | |
| 293 | // Having specify HAVING conditions for GROUP BY |
| 294 | // |
nothing calls this directly
no test coverage detected