我已经编写了MySQL查询,如下所示
"SELECT ad.UserId, l.name , Sum( ad.Amt ) AS Amount ,ad.UserDate FROM adm_advt_answer ad" +
" JOIN adm_advt_question adq ON ad.Q_ID = adq.nID" +
" INNER JOIN adm_grp_registration l ON ad.UserId = l.userid WHERE adq.Buserid = '" +
lblusername.Text + "' AND adq.Active='Y' AND ad.UserDate > DATE_SUB( CURDATE( ) , INTERVAL 1 WEEK )" +
" GROUP BY ad.UserId"
我的查询花费的时间太长,因此出现超时错误 我必须在Grid中得到结果。
我的样本输出将是
CustomerName TotalAmount UserDate
xxx 10 2/20/2014 13:01
aaa 14 2/17/2014 10:04
dddd 10 2/15/2014 9:31
ccc 1.4 2/20/2014 8:43
eeee 14 2/14/2014 10:04
ssss 14 2/20/2014 10:04