SELECT a.*,IFNULL(c.ScoreNum,0) AS ScoreNum,IFNULL(c.ScoreCount,0) AS ScoreCount
SELECT a.*,IFNULL(B.Title,'') AS Title,IFNULL(c.ScoreNum,0) AS ScoreNum,IFNULL(c.ScoreCount,0) AS ScoreCount
FROM {TableName} AS a
LEFT JOIN rb_education_surveymain AS B ON A.MainId=B.Id
LEFT JOIN (SELECT StudentSurveyId,SUM(ScoreNum) as ScoreNum,COUNT(StudentSurveyId) as ScoreCount FROM Rb_Education_StudentSurveyDetails WHERE ScoreNum>0 GROUP BY StudentSurveyId ) as c ON a.ID=c.StudentSurveyId
WHERE a.state=0");
if(where!=null)
...
...
@@ -108,8 +109,12 @@ WHERE a.state=0");
{
sb.AppendFormat(" AND A.CreateDate<='{0} 23:59:59' ",where.QEndDate);
}
if(where.MainId>0)
{
sb.AppendFormat(" and a.MainId={0}",where.MainId);