0

Seelect where Calculation from 2 entries

Hello i ned the difference from 2 entries in a table (Hour meter)

the last of the entry i get: 

 

 let myreg := Registration;
last((select 'Flt Hrs' where Luftfahrzeuge.Registration = myreg) order by Datum).TSN

but for calculation i need also the secon last of the same Registy... how can i solve this?

 

Table 'Flt Hrs'

 regards Alex

6 replies

null
    • Fred
    • 12 days ago
    • Reported - view

    I'm not sure what you are asking. Your code finds the last record of a dataset then gets the data from the TSN field. Are you asking how to get other data from the same field?

    • Ninox partner
    • RoSoft_Steven.1
    • 11 days ago
    • Reported - view

     Try:

    let myreg := Registration;
    let sel := (select 'Flt Hrs' where Luftfahrzeuge.Registration = myreg) order by Datum)
    item(r, cnt(sel) - 2).TSN
    • Alexander_Prinz
    • 11 days ago
    • Reported - view

    Thanks it work like this:

     

    let myreg := Registration;
    let sel := ((select 'Flt Hrs' where Luftfahrzeuge.Registration = myreg) order by Datum);
    item((select 'Flt Hrs' where Luftfahrzeuge.Registration = myreg) order by Datum, cnt(sel) - 2).TSN

    • Alexander_Prinz
    • 11 days ago
    • Reported - view

    The Difference between this 2 Entris wok then like this:

    Thanks

      • John_Halls
      • 10 days ago
      • Reported - view

       This can be written as

      let myReg := Registration;
      let myArray := ((select 'Flt Hrs' where Luftfahrzeuge.Registration = myReg) order by Datum);
      last(myArray).TSN - item(myArray, cnt(myArray) - 2).TSN
      

      This way you only run the select once

      Regards John

    • red_kite
    • 9 days ago
    • Reported - view

    Also you can slice the last two directly.

    let myReg := Registration;
    let lastTwo := slice((select 'Flt Hrs' where Luftfahrzeuge.Registration = myReg) order by -Datum),0,2).TSN;
    item(lastTwo, 0) - item(lastTwo, 1)
    

Content aside

  • Status Answered
  • 9 days agoLast active
  • 6Replies
  • 54Views
  • 5 Following