User ID amount payment direction 1 100 rate 1 150 rate 2, 143 fee 3 28 refund
Now to do a report DATAREPORT
At the bottom of the report have a combined item how do I have to like this total item, please pay attention to the first three is to collect fees, the fourth is a refund, thank you,
CodePudding user response:
SELECT SUM (CASE payment direction WHEN 'refund' END THEN amount - ELSE amount) AS a total amount FROM the table name