×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: SQL
Posted by: Dmitriy Lanets
Added: Apr 13, 2015 12:19 PM
Views: 17
Tags: taskmanager
  1.                         SELECT
  2.                           @task_all := (SELECT
  3.                           COUNT(*)
  4.                           FROM task_manager WHERE tsm_group='default' ) AS task_all,
  5.                           @in_work := (SELECT
  6.                           COUNT(*)
  7.                           FROM task_manager WHERE tsm_status != 'COMPLETE' AND tsm_group='default' ) AS in_work,
  8.  
  9.                           @complete := (SELECT
  10.                           COUNT(*)
  11.                           FROM task_manager WHERE tsm_status = 'COMPLETE' AND tsm_group='default') AS complete,
  12.  
  13.                           CONCAT(REPEAT('#|',@complete),REPEAT('_|',@in_work)) AS c,
  14.  
  15.                           ROUND(@complete / @task_all * 100) AS progress,
  16.  
  17.  
  18.                         (SELECT
  19.                           tsm_name
  20.                           FROM task_manager WHERE tsm_status <> 'COMPLETE' AND tsm_group='default'  ORDER BY tsm_id LIMIT 1) AS task,
  21.                        
  22.                         (SELECT
  23.                           tsm_id
  24.                           FROM task_manager WHERE tsm_status <> 'COMPLETE' AND tsm_group='default'  ORDER BY tsm_id LIMIT 1) AS task_id,       
  25.  
  26.                           (SELECT
  27.                           tsm_status
  28.                           FROM task_manager WHERE tsm_status <> 'COMPLETE' AND tsm_group='default'  ORDER BY tsm_id LIMIT 1) AS task_status,
  29.         (SELECT DATE_ADD(`date`, INTERVAL -2 HOUR) AS date_field FROM ar_ps_motors.__log ORDER BY `id` DESC LIMIT 1) AS last_activity