[thelist] Another SQL query

r937 rudy at r937.com
Wed Sep 12 11:53:40 CDT 2007


> 1) how many unique tasks have been processed 

select count(distinct task_parts.task_id_fk)
  from log
inner
  join task_parts
    on task_parts.part_id = log.task_part_fk


>  2) how many tasks have been processed total 

select count(*)
  from (
       select task_parts.task_id_fk
            , count(*) as tasks
         from log
       inner
         join task_parts
           on task_parts.part_id = log.task_part_fk   
       group
           by task_parts.task_id_fk 
       ) as logs
inner
  join (
       select task_parts.task_id_fk
            , count(*) as tasks
         from task_parts
       group
           by task_parts.task_id_fk 
       ) as parts
    on parts.task_id_fk = logs.task_id_fk
 where logs.tasks > task.tasks

rudy
http://r937.com/

    




More information about the thelist mailing list