From surenkid, 1 Month ago, written in MySQL.
Embed
  1. SET @mydate = subdate(curdate(),date_format(curdate(),'%w')-1);
  2. SELECT CONCAT(u.lastname,u.firstname) `name`
  3. ,s.`name` status_name
  4. ,i.`subject`
  5. ,i.start_date
  6. ,i.due_date
  7. ,i.closed_on
  8. ,i.done_ratio
  9. ,CONCAT('http://my.sumeils.com:3001/issues/',i.id) URL
  10. FROM issues i
  11. LEFT JOIN users u ON i.assigned_to_id = u.`id`
  12. LEFT JOIN issue_statuses s ON s.id = i.status_id
  13. WHERE (i.start_date>=@mydate OR i.due_date>=@mydate)
  14. -- AND u.id <> 5
  15. ORDER BY u.id ASC,i.done_ratio DESC,i.id ASC;