locked
how to generate a report that calculate the difference between two records for a ceratin field? RRS feed

  • Question

  • User-1538122812 posted

    Hello guys ,

    I am wondering how coud I do the following : I am building a system for a printer leasing company.I have a table called "Maintenance" which has the following fields : (,maint_id,maint_date,maint_cost,maint_type,machine_id),it will record the details for every maintenance done for a specific machine.There is also a field called "machine_reading" that is for storing the current number of papers printed by the machine.So,for example,when replacing a new toner for the printer,the current reading should be inserted in "Maintenance" table.What I want to do is to calculate the difference between the reading when the new toner has been put,and the reading when the toner has been replaced,so I know how many papers every toner could print.

    I hope this was clear enough.Please give me suggestion on how to do this.

    Thank you in advance.

    Sunday, May 27, 2012 4:22 AM

Answers

  • User-1811612959 posted
    Finding difference in SQL would solve the problem easily. Check the below link for sample queries: http://stackoverflow.com/questions/634568/how-to-get-difference-between-two-rows-for-a-column-field
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, May 27, 2012 12:15 PM
  • User346103577 posted

    Hi,

    If you are using Crystal reports than you can use running totals fields to calculate the same.

    If you want to use Sql Server Sql's then you need to create a SP which will run a loop and update a temporary table to get the final result.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, May 28, 2012 2:14 AM

All replies

  • User-1811612959 posted
    Finding difference in SQL would solve the problem easily. Check the below link for sample queries: http://stackoverflow.com/questions/634568/how-to-get-difference-between-two-rows-for-a-column-field
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, May 27, 2012 12:15 PM
  • User346103577 posted

    Hi,

    If you are using Crystal reports than you can use running totals fields to calculate the same.

    If you want to use Sql Server Sql's then you need to create a SP which will run a loop and update a temporary table to get the final result.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, May 28, 2012 2:14 AM