用PHP总结所选列的总和,我的代码是对的吗?

时间:2016-03-29 07:41:51

标签: php mysql

我正在为“价格”栏目的总销售额创建一个代码,我做得对吗???

public function gettotalsales()
{
        $stmt = $this->conn->prepare("Select SUM(Price) From tbl_orderlist where Price != '' ");
        $stmt->execute();
        return $stmt;
}

Database img

2 个答案:

答案 0 :(得分:1)

您只需编写以下行

Select SUM(Price) From tbl_orderlist

答案 1 :(得分:0)

Select SUM(Price) From tbl_orderlist