Reputation: 426
I have a table with next columns:
ID | Date | Hours |
1 20-05-2013 8:00
2 20-05-2013 2:00
I want to SUM the duplicate's hours if have the same date.
$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;
}
I want to print total of days with 8 hours worked. conclusion it's must to be 0 worked days with 8 hours because the raport have the same date (same day)
Upvotes: 0
Views: 422
Reputation: 3096
Try this:
SELECT Date, SUM(Hours) as TOTAL
FROM your_table
GROUP BY Date;
Edit:
Hard to understand what you really want but this may help:
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;
Upvotes: 5