Home > Software engineering >  A total of problem in a simple report
A total of problem in a simple report

Time:10-31

A record

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 

CodePudding user response:

Thank you very much

reference 1st floor Leftie response:
 SELECT SUM (CASE payment direction WHEN 'refund' END THEN amount - ELSE amount) AS a total amount FROM the table name 


Thank you very much

CodePudding user response:

reference 1st floor Leftie response:
 SELECT SUM (CASE payment direction WHEN 'refund' END THEN amount - ELSE amount) AS a total amount FROM the table name 


In the report can be directly write the SQL statement, please

CodePudding user response:

refer to the second floor u011478712 response:
thank you very much

Quote: refer to 1st floor Leftie response:

 SELECT SUM (CASE payment direction WHEN 'refund' END THEN amount - ELSE amount) AS a total amount FROM the table name 


Thank you very much

My database is the ACCESS2003, as if the statement can use well,
  • Related