Guest User

Untitled

a guest
Apr 20th, 2018
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.84 KB | None | 0 0
  1. mysql> select * from daily_hours order by day desc limit 10;
  2. +-------+------------+---------+--------------+---------+
  3. | id | day | user_id | type | seconds |
  4. +-------+------------+---------+--------------+---------+
  5. | 10708 | 2008-04-15 | 512 | gross | 0 |
  6. | 10709 | 2008-04-15 | 512 | paid_break | 0 |
  7. | 10710 | 2008-04-15 | 512 | unpaid_break | 0 |
  8. | 10711 | 2008-04-15 | 512 | vacation | 0 |
  9. | 10712 | 2008-04-15 | 512 | net | 0 |
  10. | 10713 | 2008-04-15 | 4153 | gross | 37730 |
  11. | 10714 | 2008-04-15 | 4153 | paid_break | 0 |
  12. | 10715 | 2008-04-15 | 4153 | unpaid_break | 4800 |
  13. | 10716 | 2008-04-15 | 4153 | vacation | 0 |
  14. | 10717 | 2008-04-15 | 4153 | net | 32930 |
  15. +-------+------------+---------+--------------+---------+
  16.  
  17.  
  18. mysql> select date_format(day,'%V %X'),
  19. user_id,
  20. type,
  21. sum(if(date_format(day,'%W')='Monday',seconds,0)) as monday, sum(if(date_format(day,'%W')='Tuesday',seconds,0)) as tuesday
  22. from daily_hours group by date_format(day,'%X %V'),user_id,type
  23. order by day desc
  24. limit 5;
  25. +--------------------------+---------+--------------+--------+---------+
  26. | date_format(day,'%V %X') | user_id | type | monday | tuesday |
  27. +--------------------------+---------+--------------+--------+---------+
  28. | 15 2008 | 512 | paid_break | 0 | 0 |
  29. | 15 2008 | 5627 | unpaid_break | 2280 | 3420 |
  30. | 15 2008 | 5693 | vacation | 0 | 0 |
  31. | 15 2008 | 5705 | net | 28167 | 29132 |
  32. | 15 2008 | 5793 | gross | 0 | 0 |
  33. +--------------------------+---------+--------------+--------+---------+
  34. 5 rows in set (0.00 sec)
Add Comment
Please, Sign In to add comment