我不知道如何显示管理员(医生)每天观看的用户(病人)数量。 我有这份每日报告,可以打印每天的总销售额,但如果我需要显示他看到的用户(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
- 开始日期时间
- 荣誉 varchar
- id_paciente int
我需要这样的报告显示:
日期(fecha)--------total_user(total de pacientes)-----total_sales(total diario)
- 2013年6月10日----------25-------------------------------------------- --650.00
- 2013年6月9日----------10-------------------------------------------- --250.00
- 2013年6月8日----------15-------------------------------------------- --375.00
但现在像这样显示:
日期(fecha)--------total_user(total de pacientes)-----total_sales(total diario)
- 2013 年 6 月 10 日----------65725---------------------------- --650.00
- 09-junio-2013----------34510-------------------------------------------- --250.00
- 08-junio-2013----------49815-------------------------------------------- --375.00
id_paciente 有 17,000 个用户,是表 PACIENTES 的 FK
最佳答案
问题是这样的:
SUM(id_paciente) AS total_pacientes
您不想对 id 求和。你想数一下它们。将其替换为:
count(id_paciente) AS total_pacientes
关于mysql - mysql+PDO 中的每日销售额和用户数量报告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17203627/