SELECT SUM(Score_core.score) / 2 AS Expr1
FROM Score_core INNER JOIN
Core_Competency ON Core_Competency.id_core = Score_core.id_core
WHERE (Score_core.id_evaluatee = 'E000000001')
GROUP BY Core_Competency.id_core
ข้างบนนี้จะออกค่า sum ออกมาค่ะ
แต่พอจะเพื่มให้มีคำถามข้างหน้าออกมา เพิ่ม Core_Competency.core ทำไมมัน error ค่ะ
Code (SQL)
SELECT Core_Competency.core,SUM(Score_core.score) / 2 AS Expr1
FROM Score_core INNER JOIN
Core_Competency ON Core_Competency.id_core = Score_core.id_core
WHERE (Score_core.id_evaluatee = 'E000000001')
GROUP BY Core_Competency.id_core
ต้องเพิ่ม Core_Competency.core ใน GROUP BY ด้วย Code
SELECT Core_Competency.core,SUM(Score_core.score) / 2 AS Expr1
FROM Score_core INNER JOIN
Core_Competency ON Core_Competency.id_core = Score_core.id_core
WHERE (Score_core.id_evaluatee = 'E000000001')
GROUP BY Core_Competency.id_core, Core_Competency.core
SELECT Core_Competency.core,ROUND(SUM(Score_core.score) / 2,2) AS Expr1
FROM Score_core INNER JOIN
Core_Competency ON Core_Competency.id_core = Score_core.id_core
WHERE (Score_core.id_evaluatee = 'E000000001')
GROUP BY Core_Competency.id_core, Core_Competency.core
SELECT Core_Competency.core,ROUND(SUM(Score_core.score) / 2,-2) AS Expr1
FROM Score_core INNER JOIN
Core_Competency ON Core_Competency.id_core = Score_core.id_core
WHERE (Score_core.id_evaluatee = 'E000000001')
GROUP BY Core_Competency.id_core, Core_Competency.core
Imports System.Data
Partial Class GridViewTestPage
Inherits System.Web.UI.Page
Protected Sub form1_Load(sender As Object, e As System.EventArgs) Handles form1.Load
If Not Me.IsPostBack Then
Me.LoadData()
End If
End Sub
Private Sub LoadData()
Dim dtable As New DataTable
dtable.Columns.Add("Section", GetType(System.String))
dtable.Columns.Add("Percentage", GetType(System.Decimal))
dtable.Rows.Add("Bangkok", 0.8)
dtable.Rows.Add("Phuket", 0.2)
gvMain.DataSource = dtable
gvMain.DataBind()
End Sub
End Class