0

我有一个包含下一列的表格:

ID |    Date    | Hours |
1    20-05-2013   8:00
2    20-05-2013   2:00

如果日期相同,我想求和重复的时间。

  $sql2=mysql_query("SELECT count(distinct data_raport), SUM(ore) as TOTAL FROM sohy_works  WHERE data_raport BETWEEN '".$_GET['data']."' AND '".$_GET['data-2']."' AND numes LIKE '%".$_GET['numes']."%' AND ore <= '8:00' GROUP BY data_raport ");
while ($row2=mysql_fetch_array($sql2)) {
    $total = $row2[0];
    echo "8 hours/day: " . $total;

}

我想打印工作 8 小时的总天数。结论必须是 0 个工作日和 8 小时,因为报告具有相同的日期(同一天)

4

2 回答 2

5

尝试这个:

SELECT Date, SUM(Hours) as TOTAL
FROM your_table
GROUP BY Date;

编辑:

很难理解你真正想要什么,但这可能会有所帮助:

SELECT COUNT(*) as 8_Hours_day
FROM (
    SELECT Date, SUM(Hours) as Total_Hours
    FROM your_table
    GROUP BY Date
    HAVING Total_Hours = 8
) T;
于 2013-05-29T11:54:51.753 回答
2
SELECT SUM(Hours) from Table group by Date
于 2013-05-29T11:54:39.257 回答