$sql=" select a.*,sum(b.t1),sum(b.t2),";
$sql.="sum(b.t3),sum(b.t4),sum(b.t5),sum(b.t6),sum(b.t7),sum(b.t8),sum(b.t9),sum(b.t10),";
$sql.="sum(b.t11),sum(b.t12),sum(b.t13),sum(b.t14),sum(b.t15),sum(b.t16),sum(b.t17),sum(b.t18),sum(b.t19),";
$sql.="c.classname,d.implementernm ";
$sql.=" from trainingsurvey a,trainingsurvey_dt b ";
$sql.= " Left Join luclass c on a.courseid = c.classid";
$sql.= " Left Join dms_implementer d on a.implementernm = d.implementercd";
$sql.=" where a.eventid=b.eventid"
error ออกมาแบบนี้ค่ะ
Code
Warning: mssql_query() [function.mssql-query]: message: The multi-part identifier "a.courseid" could not be bound. (severity 16) in C:\xampp\htdocs\itapps\survey\surveyshow.php on line 149
Warning: mssql_query() [function.mssql-query]: message: The multi-part identifier "a.implementernm" could not be bound. (severity 16) in C:\xampp\htdocs\itapps\survey\surveyshow.php on line 149
$sql = " Select a.eventid,a.stdate, b.classname , c.implementernm , ";
$sql.= " SUM(d.t1) as s1,SUM(d.t2)as s2,SUM(d.t3) as s3,SUM(d.t4) as s4,SUM(d.t5) as s5,SUM(d.t6) as s6,";
$sql.= " SUM(d.t7) as s7,SUM(d.t8) as s8,SUM(d.t9) as s9,";
$sql.= " SUM(d.t10) as s10,SUM(d.t11) as s11,SUM(d.t12) as s12,SUM(d.t13) as s13,SUM(d.t14) as s14,SUM(d.t15) as s15,";
$sql.= " SUM(d.t16) as s16,SUM(d.t17) as s17,SUM(d.t18) as s18,SUM(d.t19) as s19 ,COUNT(d.eventid) as c1 ";
$sql.= " FROM trainingsurvey a ";
$sql.= " Inner Join luclass b on a.courseid = b.classid ";
$sql.= " Left Join dms_implementer c on a.implementercd = c.implementercd ";
$sql.= " Left Join trainingsurvey_dt d on a.eventid = d.eventid ";
$sql.= " group by a.eventid,b.classname,a.fndate,a.stdate,c.implementernm";
$sql.=" having year(stdate)=".$filter_year;
$sql.=" and month(stdate)=".$filter_month;
$sql.= " Order by a.stdate ";
โค้ดบนไม่ได้เพราะว่า select * ทั้งตารางแรก แต่ Group by ไม่หมดค่ะเลยไม่ได้