我不知道管理员(医生)每天如何显示每天的用户数量(pacientes)... 我有这个每日报告,它打印出我每天的总销售量,但如果我需要显示用户数量(pacientes),他看到(如10 pacientes)代码打印2000或更多..
你可以帮我解决这个问题吗?<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>Fecha</th>
<th>Total Pacientes vistos</th>
<th>Total diario</th>
</tr>
</thead>
<tbody>
<tr>
<?
include 'config.php';
$sql = $conn->prepare("SELECT DATE(start) AS date, SUM(id_paciente) AS total_pacientes, SUM(honorario) AS total_diario
FROM CITAS WHERE start >= CURDATE() AND start < CURDATE() + INTERVAL 1 DAY ORDER BY start ASC");
$sql->execute();
while($row = $sql->fetch(PDO::FETCH_ASSOC)) {
?>
<td class="center"><? echo $row['date']; ?></td>
<td class="center"><? echo $row['total_pacientes']; ?></td>
<td class="center"><? echo $row['total_diario']; ?></td>
</tr> <? } ?>
</tbody>
</table>
表CITAS
我需要报告显示如下:
date(fecha)-------- total_user(total de pacientes)----- total_sales(total diario)
但是现在就这样表明:
date(fecha)-------- total_user(total de pacientes)----- total_sales(total diario)
id_paciente有17,000个用户,是表PACIENTES的FK
答案 0 :(得分:1)
问题在于:
SUM(id_paciente) AS total_pacientes
您不想总结ID。你想要算数。替换为:
count(id_paciente) AS total_pacientes