( SELECT COALESCE ( count(*), 0 ) FROM logpm_distribution_stock lds WHERE ldsl.id = lds.stock_list_id AND lds.reservation_id =ldrsl.reservation_id AND lds.tenant_id = '627683' ) AS readyStock,
(
SELECT
COALESCE(count(*), 0)
SELECT COALESCE
(count(*), 0)
FROM
logpm_distribution_stock lds
logpm_dis_stock_list_detail ldsld
WHERE
ldsl.id = lds.stock_list_id
) readyStock,
( SELECT COALESCE ( count(*), 0 ) FROM logpm_dis_stock_list_detail ldsld WHERE ldsl.id = ldsld.stock_list_id AND ldrsl.reservation_id = ldsld.reservation_id AND ldsld.stock_locking_status = '20' ) AS loadedinNumber,
( SELECT COALESCE ( count(*), 0 ) FROM logpm_dis_stock_list_detail ldsld WHERE ldsl.id = ldsld.stock_list_id AND ldrsl.reservation_id = ldsld.reservation_id AND ldsld.stock_signfo_status = '20' ) AS signedinNumber,
ldsl.storage_location goodsAllocation,
ldsl.cargo_number cargoNumber
ldsl.id = ldsld.stock_list_id
AND ldrsl.reservation_id = ldsld.reservation_id
AND ldsld.stock_locking_status = '20'
AND ldsld.tenant_id = '627683'
) AS loadingNumber,
(
SELECT COALESCE
( count(*), 0 )
FROM
logpm_dis_stock_list_detail ldsld
WHERE
ldsl.id = ldsld.stock_list_id
AND ldrsl.reservation_id = ldsld.reservation_id
AND ldsld.stock_signfo_status = '20'
AND ldsld.tenant_id = '627683'
) AS signedingNumber,
ldsl.storage_location AS goodsAllocation,
ldsl.cargo_number AS cargoNumber
FROM
logpm_distribution_reservation_stocklist ldrsl
JOIN logpm_distribution_signfor lds on lds.reservation_id = ldrsl.reservation_id
JOIN logpm_distribution_delivery_list lddl on lddl.id = lds.delivery_id
join logpm_distribution_stock_list ldsl on ldrsl.stocklist_id = ldsl.id
JOIN logpm_distribution_signfor lds ON lds.reservation_id = ldrsl.reservation_id
JOIN logpm_distribution_delivery_list lddl ON lddl.id = lds.delivery_id
JOIN logpm_distribution_stock_list ldsl ON ldrsl.stocklist_id = ldsl.id