รายละเอียดของการตอบ ::
Ok ทำแบบที่ K.TOR_CHEMISTRY แนะนำค่ะ
ขอถามต่อนิดนึงค่ะ เรื่องการแสดงข้อมูล พอดีแสดงข้อมูลใน gridview เวลา run ในโปรแกรม ฟิลด์มันแสดงสลับตำแหน่งกัน แต่พอลอง copy code จากหน้า vb มา run ใน sql ดู มันกลับแสดงถูก เป็นเพราะอะไรอ่ะคะ
อันนี้ที่ SQL
อันนี้ที่ VB
Code
Dim strselectfr As String = "SELECT DATENAME(month,r.c_date),f.f_type,ISNULL(sum(r.c_wood),0),ISNULL(sum(r.c_swood),0),ISNULL(sum(r.c_woodfr),0),ISNULL(sum(r.c_color),0),ISNULL(sum(r.c_fitting),0),ISNULL(sum(r.c_box),0),ISNULL(sum(r.c_pad),0),ISNULL(sum(r.c_pvc),0),ISNULL(sum(r.c_sponge),0),ISNULL(sum(r.c_waste),0),ISNULL(sum(r.c_total),0),ISNULL(sum(p.pt_produc),0),CASE WHEN ISNULL(sum(p.pt_produc),0) <= 0 THEN 0 ELSE (ISNULL(sum(r.c_total),0)*100)/ISNULL(sum(p.pt_produc),0) END as tnetdiff FROM PTrawmat r left join PTdeptpr f on r.c_type = f.f_type left join PTsum p on r.c_type=p.pt_typed where p.pt_date = r.c_date and p.pt_typed = r.c_type and month(r.c_date) between '" & cboMonth01.SelectedIndex + 1 & "' and '" & cboMonth02.SelectedIndex + 1 & "' and year(r.c_date) between '" & cboYear01.Text & "' and '" & cboYear02.Text & "' and r.c_type='" & cmbincome.SelectedValue & "' group by month(r.c_date),DATENAME(month,r.c_date),f.f_type"