У меня есть следующая таблица, в которой я хочу собрать все orders_qty с 2019 по 2020 год, мой запрос как
Запрос как:
$get_details_year= DB::select('SELECT EXTRACT(YEAR FROM deliver_date),GROUP_CONCAT(orders_qty) from orders where order_status=? and EXTRACT(YEAR FROM deliver_date) between ? AND ? GROUP BY EXTRACT(YEAR FROM deliver_date)',[6,'2019','2020']);
Таблица:
orders_id orders_qty delivery_date
1 2,2, 2019-02-01
2 2,2, 2020-02-05
3 1, 2020-02-05
Мой результат:
array:2 [▼
0 => {#430 ▼
+"EXTRACT(YEAR FROM deliver_date)": 2019
+"GROUP_CONCAT(orders_qty)": "2,2,"
}
1 => {#431 ▼
+"EXTRACT(YEAR FROM deliver_date)": 2020
+"GROUP_CONCAT(orders_qty)": "2,2,,1,"
}
]
Исключенный результат:
array:2 [▼
0 => {#429 ▼
+"EXTRACT(YEAR FROM deliver_date)": 2019
+"GROUP_CONCAT(orders_qty)": "2,2,"
}
1 => {#430 ▼
+"EXTRACT(YEAR FROM deliver_date)": 2020
+"GROUP_CONCAT(orders_qty)": "2,2,1,"
}
]