I have a MySQL table where employee login and logout timings are recorded. Here in the in-out column 1-represents login and 0-represents logout.
[id] [Us
Rudi's line of thinking is correct. If you want the hours with decimal, use UNIX_TIMESTAMP() on the date_time field, otherwise the returned type will be a DATETIME (hard to parse). Here's the result for your first 4 lines of data plus 2 more for a different day:
SELECT
`user_id`,
DATE(`date_time`) AS `date`,
SUM(UNIX_TIMESTAMP(`date_time`)*(1-2*`in_out`))/3600 AS `hours_worked`
FROM `test`
GROUP BY date(`date_time`), `user_id`;
+---------+------------+--------------+
| user_id | date | hours_worked |
+---------+------------+--------------+
| 1 | 2011-01-20 | 3.2567 |
| 1 | 2011-01-21 | 3.0000 |
+---------+------------+--------------+