Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 9 of 9 for sum (0.18 sec)

  1. go.sum

    qqxhb <******@****.***> 1692452011 +0800
    Plain Text
    - Registered: Sun Apr 28 09:35:09 GMT 2024
    - Last Modified: Sat Aug 19 13:33:31 GMT 2023
    - 336 bytes
    - Viewed (0)
  2. tests/scan_test.go

    		t.Errorf("Should find expected results")
    	}
    
    	var ages int
    	if err := DB.Table("users").Where("name = ? or name = ?", user2.Name, user3.Name).Select("SUM(age)").Scan(&ages).Error; err != nil || ages != 30 {
    		t.Fatalf("failed to scan ages, got error %v, ages: %v", err, ages)
    	}
    
    	var name string
    Go
    - Registered: Sun Apr 28 09:35:09 GMT 2024
    - Last Modified: Sat May 28 14:18:07 GMT 2022
    - 8.2K bytes
    - Viewed (0)
  3. chainable_api.go

    	tx.Statement.Joins = append(tx.Statement.Joins, join{Name: query, Conds: args, JoinType: joinType})
    	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)
    Go
    - Registered: Sun Apr 28 09:35:09 GMT 2024
    - Last Modified: Wed Apr 17 03:38:55 GMT 2024
    - 14.3K bytes
    - Viewed (1)
  4. schema/naming.go

    	if ns.IdentifierMaxLength == 0 {
    		ns.IdentifierMaxLength = 64
    	}
    
    	if utf8.RuneCountInString(formattedName) > ns.IdentifierMaxLength {
    		h := sha1.New()
    		h.Write([]byte(formattedName))
    		bs := h.Sum(nil)
    
    		formattedName = formattedName[0:ns.IdentifierMaxLength-8] + hex.EncodeToString(bs)[:8]
    	}
    	return formattedName
    }
    
    var (
    	// https://github.com/golang/lint/blob/master/lint.go#L770
    Go
    - Registered: Sun Apr 28 09:35:09 GMT 2024
    - Last Modified: Mon Oct 30 09:15:49 GMT 2023
    - 5.2K bytes
    - Viewed (0)
  5. clause/expression_test.go

    	}, {
    		Expressions: []clause.Expression{
    			clause.Eq{Column: clause.Expr{SQL: "SUM(?)", Vars: []interface{}{clause.Column{Name: "id"}}}, Value: 100},
    		},
    		ExpectedVars: []interface{}{100},
    		Result:       "SUM(`id`) = ?",
    	}, {
    		Expressions: []clause.Expression{
    			clause.Gte{Column: clause.Expr{SQL: "SUM(?)", Vars: []interface{}{clause.Column{Table: "users", Name: "id"}}}, Value: 100},
    		},
    Go
    - Registered: Sun Apr 28 09:35:09 GMT 2024
    - Last Modified: Thu Aug 10 05:34:33 GMT 2023
    - 8.4K bytes
    - Viewed (0)
  6. tests/.gitignore

    go.sum...
    Plain Text
    - Registered: Sun Apr 28 09:35:09 GMT 2024
    - Last Modified: Tue Jul 28 06:46:48 GMT 2020
    - 7 bytes
    - Viewed (0)
  7. tests/joins_test.go

    	iv := DB.Table(`table_invoices`).Select(`seller, SUM(total) as total, SUM(paid) as paid, SUM(balance) as balance`).Group(`seller`)
    	stmt = dryDB.Table(`table_employees`).Select(`id, name, iv.total, iv.paid, iv.balance`).Joins(`LEFT JOIN (?) AS iv ON iv.seller = table_employees.id`, iv).Scan(&user).Statement
    Go
    - Registered: Sun Apr 28 09:35:09 GMT 2024
    - Last Modified: Wed Apr 26 14:19:32 GMT 2023
    - 13.5K bytes
    - Viewed (1)
  8. tests/group_by_test.go

    	var total int
    	if err := DB.Model(&User{}).Select("name, sum(age)").Where("name = ?", "groupby").Group("name").Row().Scan(&name, &total); err != nil {
    		t.Errorf("no error should happen, but got %v", err)
    	}
    
    	if name != "groupby" || total != 60 {
    		t.Errorf("name should be groupby, but got %v, total should be 60, but got %v", name, total)
    	}
    
    Go
    - Registered: Sun Apr 28 09:35:09 GMT 2024
    - Last Modified: Thu Jan 06 07:02:53 GMT 2022
    - 3.3K bytes
    - Viewed (0)
  9. tests/sql_builder_test.go

    		t.Error("Raw sql to update records")
    	}
    
    	DB.Exec("update users set age=? where name = ?", gorm.Expr("age * ? + ?", 2, 10), "jinzhu-raw")
    
    	var age int
    	DB.Raw("select sum(age) from users where name = ?", "jinzhu-raw").Scan(&age)
    
    	if age != ((1+10+20)*2 + 30) {
    		t.Errorf("Invalid age, got %v", age)
    	}
    }
    
    func TestRowsWithGroup(t *testing.T) {
    	users := []User{
    Go
    - Registered: Sun Apr 28 09:35:09 GMT 2024
    - Last Modified: Fri Jan 12 08:42:21 GMT 2024
    - 16.7K bytes
    - Viewed (0)
Back to top