Just wondering if anyone can help me with my SQL query. This one below is delivering me duplicates lines. Can anyone see why?
SELECT
DATE(J.date_scheduled) AS date_scheduled,
J.id AS job_id,
J.facility_id AS facility_id,
F.name AS facility_name,
J.resident_id AS resident_id,
CONCAT(R.last_name, ', ', R.first_name) AS resident_full_name,
DATE(J.created_at) AS job_created_date,
J.examination_type AS examination_type,
J.region_of_examination AS region_of_examination,
J.urgent AS urgent,
CONCAT(U.first_name, ' ', U.last_name) AS operator_name,
J.doctor_id AS doctor_id,
J.regular_doctor_first_name AS regular_doctor_first_name,
J.regular_doctor_last_name AS regular_doctor_last_name,
D.provider_number AS provider_number,
J.status AS status,
F.postcode AS facility_postcode,
F.state AS facility_state,
J.ris_code AS RIS_code,
J.payment_by,
I.status AS payment_status,
J.job_total * .01 AS job_total,
IF(ME.total_cost > 0, ME.total_cost, 0) AS total_cost,
(COALESCE((J.job_total * .01), 0) + COALESCE((ME.total_cost), 0)) AS mytotal,
JSON_EXTRACT(`ME`.`fixed_cost_items`,'$[0].item_cost') AS `fixed_cost_amount`,
JR.gap_amount AS GAP_amount,
JR.gap_deposit_as_part_of AS GAP_deposit_as_part_of,
JR.gap_deposit_date AS GAP_deposit_date,
JR.rebate_method AS rebate_method,
JR.rebate_amount AS rebate_amount,
JR.rebate_verification AS rebate_verification,
JR.rebate_deposit_as_part_of AS rebate_deposit_as_part_of,
JR.rebate_deposit_date AS rebate_deposit_date,
JR.rebate_57541_amount AS rebate_57541_amount,
JR.private_fee_amount AS private_fee_amount
FROM
jobs J
LEFT JOIN
facilities F ON J.facility_id = F.id
LEFT JOIN
residents R ON J.resident_id = R.id
LEFT JOIN
doctors D ON J.doctor_id = D.id
LEFT JOIN
job_reconciliations JR ON JR.job_id = J.id
LEFT JOIN
medicare_exports ME ON ME.job_id = J.id
LEFT JOIN
users U ON U.id = J.user_id
LEFT JOIN
invoices I ON I.ref_id = J.id
ORDER BY J.id DESC