0
我有四個支點,我從這個樣子拉着數據:生成列導致
tracked_work_by_users_by_operation_pivot:
+-------------------+---------------+---------------+-----------------------+---------------+
| DATE(start_time) | userid | operation_id | Time estimated | Time Elapsed |
+-------------------+---------------+---------------+-----------------------+---------------+
| 1/2/2011-1/8/2011 | jsmith | 11| 40| 40|
| 1/2/2011-1/8/2011 | jsmith | 10| 20| 24|
+-------------------+---------------+---------------+-----------------------+---------------+
faults_by_user_pivot:
+-------------------+---------------+---------------+-----------------------+----------+
| date(date_entered)| userid | operation_id | Major | Minor |
+-------------------+---------------+---------------+-----------------------+----------+
| 1/2/2011-1/8/2011 | jsmith | 11| 2 | 1|
+-------------------+---------------+---------------+-----------------------+----------+
paid_hours_by_user_pivot:
+-------------------+---------------+---------+
|date_range | userid | Total |
+-------------------+---------------+---------+
| 1/2/2011-1/8/2011 | jsmith | 40 |
+-------------------+---------------+---------+
tracked_work_by_users_pivot:
+-------------------+---------------+---------+
|DATE(start_time) | userid | Total |
+-------------------+---------------+---------+
| 1/2/2011-1/8/2011 | jsmith | 24 |
| | | |
+-------------------+---------------+---------+
我需要做的是編譯爲每個用戶每次操作的報告。從我看到這樣做的最好辦法是有類似的格式:
+--------------+--------------+ +--------------+--------------+
| jsmith | packaging | | jsmith | machining |
+--------------------+--------------+--------------+----------------+--------------+--------------+--------------+--------------+----------------+--------------+--------------+
| DATE | time_elapsed | hours_worked | estimated_work | minor_faults | major_faults | time_elapsed | hours_worked | estimated_work | minor_faults | major_faults |
+--------------------+--------------+--------------+----------------+--------------+--------------+--------------+--------------+----------------+--------------+--------------+
| 1/2/2011-1/8/2011 | 24 | 40 | 36 | 1 | 2 | 24 | 40 | 36 | 1 | 2 |
+--------------------+--------------+--------------+----------------+--------------+--------------+--------------+--------------+----------------+--------------+--------------+
這樣JSMITH將加工和包裝單獨的條目,因爲我們希望能夠排名使他對所有加工經營和所有包裝經營者。我怎樣才能最好地做到這一點,以便我每次添加新用戶時都不必再添加12個條目(因爲有12個操作)?