Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SELECT
- *,
- ROUND(a.totalQty / a.totalHours, 2) as AVERAGE
- FROM
- (
- select
- l.created_by,
- dur.duration/ 3600 as totalHours,
- sum(qty.qty) as totalQty
- from
- fahasa_suborder_log l
- JOIN (
- SELECT created_by, sum(duration) as duration from (
- SELECT
- created_by,
- duration,
- created_at
- FROM
- fahasa_suborder_log l
- where
- l.`action` = 'picking'
- and date(l.created_at) >= '2019-8-1'
- and DATE_FORMAT(l.created_at, '%H:%i:%s') BETWEEN TIME_FORMAT('8:00:00', '%H:%i:%s') AND TIME_FORMAT('10:00:00', '%H:%i:%s')
- and l.duration is not null
- group by
- created_by,created_at
- ) a group by a.created_by
- ) dur on
- l.created_by = dur.created_by
- JOIN (
- SELECT
- suborder_id,
- sum(qty) as qty
- FROM
- fahasa_suborder_item
- group by
- suborder_id) qty on
- qty.suborder_id = l.suborder_id
- where
- l.`action` = 'picking'
- and date(l.created_at) >= '2019-8-1'
- and DATE_FORMAT(l.created_at, '%H:%i:%s') BETWEEN TIME_FORMAT('8:00:00', '%H:%i:%s') AND TIME_FORMAT('10:00:00', '%H:%i:%s')
- and l.duration is not null
- group by
- l.created_by ) a;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement