我想要得到在一个特定的一个月所做的支付的总和可以说从1月至3月在我的网站。 我的表是设备有钱和加入列,但加入列有日期和时间。 如果可能,我想使用这种方法,但是这个片段是用于奖品总和的。我怎样才能得到在某个月的所有产品的总和在mysql
if(isset($ _ POST ['moneyMade'])){ $ moneyMade = 0;
$query = "select SUM(Money) from users where Joined<='2016-11-01 00:00:00' and Joined>='2016-11-31 00:00:00'";
//if (!$query) { echo 'MySQL Error: ' . mysqli_error(); exit; }
//$query="select * from equipments ";
$result = mysqli_query($conn,$query);
while ($row = mysqli_fetch_assoc($result)){ /* Fetch a result row as an associative array */
/*while ($row = mysqli_result($result)){*/
$moneyMade +=$row['Money'];
}
echo "Money made for this month is ". $moneyMade;
}
我怎样才能实现这一点使用PHP和一些SQL? 谢谢。
显示您的查询或您已经完成的工作 – Karthi
分享一些虚拟数据和您尝试的查询? –
尝试像这样'select SUM(amt)from tab_name where DateTime' <='2016-11-01 00:00:00'和DateTime> = 2016-11-31 00:00:00'。 ** – Karthi