I want to get the sum of the two tables.
1-1.hospital_payment_data table
1-2.hospital_payment_data table data
2-1.advenced_payment table
2-2 advenced_payment table data
I want result
However, sending the query as follows results.
SELECT COUNT(IF(treatment_fees_check_division = '선수금',
treatment_fees_check_division, NULL)) AS COUNT,
SUM(CASE WHEN treatment_fees_check_division = '선수금'
THEN treatment_fees_difference END) + SUM(advenced_amount
) AS if_treatment_fees_check_division,
SUM(advenced_amount) AS sum_init_amount
FROM
(
SELECT treatment_fees_check_division, treatment_fees_difference,
init_amount, advenced_amount
FROM hospital_payment_data , advenced_payment
)AS a
bad result
How do I fix the query? I'd like your posture, please.
Is this what you are looking for?
SELECT ( SELECT SUM(...) FROM t1 ... ) +
( SELECT SUM(...) FROM t2 ... ) AS sum_of_tables
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.