【发布时间】:2011-08-08 19:37:31
【问题描述】:
我有四张桌子:
- task - 有一个 batch_id 和估计完成任务需要多长时间
- 批次 - 任务组
- batch_log - 条目显示每个任务的工作时间,并带有工作人员的用户 ID。
- 操作 - 批次运行的机器类型、油漆、丝网印刷等。
我如何让每个用户的每个批次工作、每个批次日志中这些批次 ID 的总运行时间以及该批次的每个任务 ID 的总估计值?
编辑:
表格:
task
id estimated_nonrecurring estimated_recurring batch_id
batch
id operation_id date_entered
batch_log
id userid batch_id time_elapsed
operation
id name
我在想:
get each user;
get a list of distinct batch_ids that they worked on;
get a sum of all the time_elapsed from each batch_log for those batch id;
get all the non_recurring and the recurring for each task with each batch_id;
so that the result is like
userid, operation, batch_id, total_elapsed, total_estimate, date_entered
这样做的原因是可以对用户的工作效率进行评分,并在 Excel 中使用这些查询。我想我可能需要进行两个查询:
- 批处理日志
- 用于获取每批次的估计总数的查询
【问题讨论】:
标签: sql relationships