Hi there,
Both Earnings and Deductions are tables that store data in the Salary Detail child doctype (called tabSalary Detail in mariadb). To get that data, you just need to do a join in your sql query on tabSalary Slip.name = tabSalary Detail.parent