These are chat archives for jinzhu/gorm

May 2016
Himanshu Raj
May 23 2016 21:38
folks, have a question about using sum method. Following stmt is always returning 0:
handle := cxdb.db.Model(&types.item{}).Select("sum(num) as total").Where("status = ?", stat).Scan(&t)
t is defined as:
type Temp struct {
total int
var t Temp
Any idea why? I tried the pattern shown as example:
rows, err := db.Table("orders").Select("date(created_at) as date, sum(amount) as total").Group("date(created_at)").Rows()
for rows.Next() {
It didn't help