如何计算 php 中数据表列的总和
How to calculate the sum of the datatable column in php
我有一个包含 5 列的数据表:
sl, Doctor, Appointments, fees
DataTable 包含 4 行。
我想将费用总和列显示为 "Total fees"
这样做的最佳方法是什么?
您需要使用SUM()
功能。如果您的 table 名称是 DataTable,这是您的查询:
SELECT SUM(fees) as 'Total fees' FROM DataTable
阅读更多信息:
如果您使用 DataTable
插件显示表格,请尝试计算总和
var table = $('#example').DataTable();
table.column( 4 ).data().sum(); // as fees is your fourth column
更多信息:
http://www.datatables.net/plug-ins/api/sum()#
https://datatables.net/examples/plug-ins/api.html
对于正常的数据库操作,请尝试使用 SUM
聚合方法
进行简单查询
SELECT SUM(fees) as 'Total fees' FROM your_table_name
我有一个包含 5 列的数据表:
sl, Doctor, Appointments, fees
DataTable 包含 4 行。
我想将费用总和列显示为 "Total fees"
这样做的最佳方法是什么?
您需要使用SUM()
功能。如果您的 table 名称是 DataTable,这是您的查询:
SELECT SUM(fees) as 'Total fees' FROM DataTable
阅读更多信息:
如果您使用 DataTable
插件显示表格,请尝试计算总和
var table = $('#example').DataTable();
table.column( 4 ).data().sum(); // as fees is your fourth column
更多信息:
http://www.datatables.net/plug-ins/api/sum()#
https://datatables.net/examples/plug-ins/api.html
对于正常的数据库操作,请尝试使用 SUM
聚合方法
SELECT SUM(fees) as 'Total fees' FROM your_table_name