SELECT "ID", "Acompte", "Total", "Total" - "Acompte", IFNULL( "Total", 0 ) - IFNULL( "Acompte", 0 ) FROM "Table1"