我试图按不同的日期对数据表中的一列求和,并在文本框中显示该值,但只有我获得了该列中的第一行值而不是总和,我附上了图片,并且我的代码是
Dim dt As DataTable = New DAL().selectdatatable(String.Format("
SELECT
SUM(PT.PT_Paid) AS SumOfPT_Paid
, SUM(PT.PT_Remain) AS SumOfPT_Remain
, PT.PT_Date
FROM
PT
GROUP BY
PT.PT_Date
HAVING
(
(
(
PT.PT_Date
)
>=#{0}#
AND
(
PT.PT_Date
)
<=#{1}#
)
)
;", dateshow.Value.ToString("dd/MM/yyyy"), dateshow2.Value.ToString("dd/MM/yyyy")))
If dt.Rows.Count > 0 Then
txtin.Text = dt.Rows(0)(0).ToString
txtremain.Text = dt.Rows(0)(1).ToString
Else
txtin.Text = "0"
txtremain.Text = "0"
End If
数据: