简体   繁体   中英

How to Subtract one cell to next row cell in sql

is it possible subtract one cell value new row cell value in sqlite?

Example:

  | d1   | 
  |3000  | 
  |4000  |

In d1 column, cell no.1 (3000) - cell no.2(4000)

Edit:

   Date       id   idCl nameCl    opening   dr     closing
1-9-2016     10L   CL-J  Jon        0      2000     2000
22-9-2016    20L   CL-J  Jon       2000    1000     3000
1-9-2016     10L   CL-J  Jon       3000    2000     5000 

In your particular case, because are only two rows you can use

 SELECT MIN(d1) - MAX(d1)
 FROM YourTable.

Now if you have a bigger table you need do a SELF JOIN . But then you need provide more data and desire ouput.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM