Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 3 of 3 for Total (0.13 sec)

  1. chainable_api.go

    	return
    }
    
    // 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)
    func (db *DB) Group(name string) (tx *DB) {
    	tx = db.getInstance()
    
    	fields := strings.FieldsFunc(name, utils.IsValidDBNameChar)
    	tx.Statement.AddClause(clause.GroupBy{
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Wed Apr 17 03:38:55 GMT 2024
    - 14.3K bytes
    - Viewed (1)
  2. tests/sql_builder_test.go

    	DB.Create(&users)
    
    	rows, err := DB.Select("name, count(*) as total").Table("users").Group("name").Having("name IN ?", []string{users[0].Name, users[1].Name}).Rows()
    	if err != nil {
    		t.Fatalf("got error %v", err)
    	}
    
    	defer rows.Close()
    	for rows.Next() {
    		var name string
    		var total int64
    		rows.Scan(&name, &total)
    
    		if name == users[0].Name && total != 3 {
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Fri Jan 12 08:42:21 GMT 2024
    - 16.7K bytes
    - Viewed (0)
  3. tests/query_test.go

    	}); result.Error != nil || result.RowsAffected != 6 {
    		t.Errorf("Failed to batch find, got error %v, rows affected: %v", result.Error, result.RowsAffected)
    	}
    
    	if totalBatch != 6 {
    		t.Errorf("incorrect total batch, expects: %v, got %v", 6, totalBatch)
    	}
    
    	var count int64
    	DB.Model(&User{}).Where("name = ?", "find_in_batches_new").Count(&count)
    	if count != 6 {
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Thu Apr 25 12:22:53 GMT 2024
    - 49.8K bytes
    - Viewed (0)
Back to top