Subtract
Subtract the value in register P1 from the value in register P2 and store the result in register P3.
An example
1 of the 178 statements we compiled against the sample database use Subtract. This is the one with the shortest program; the rows that use Subtract are highlighted.
SELECT ms / 1000, ms % 1000, ms * 2, ms - 1, ms + 1 FROM tracks
| addr | opcode | p1 | p2 | p3 | p4 | p5 |
|---|---|---|---|---|---|---|
| 0 | Init | 0 | 16 | 0 | 0 | |
| 1 | OpenRead | 0 | 4 | 0 | 4 | 0 |
| 2 | Rewind | 0 | 15 | 0 | 0 | |
| 3 | Column | 0 | 3 | 6 | 0 | |
| 4 | Divide | 7 | 6 | 1 | 0 | |
| 5 | Column | 0 | 3 | 6 | 0 | |
| 6 | Remainder | 7 | 6 | 2 | 0 | |
| 7 | Column | 0 | 3 | 6 | 0 | |
| 8 | Multiply | 8 | 6 | 3 | 0 | |
| 9 | Column | 0 | 3 | 6 | 0 | |
| 10 | Subtract | 9 | 6 | 4 | 0 | |
| 11 | Column | 0 | 3 | 6 | 0 | |
| 12 | Add | 9 | 6 | 5 | 0 | |
| 13 | ResultRow | 1 | 5 | 0 | 0 | |
| 14 | Next | 0 | 3 | 0 | 1 | |
| 15 | Halt | 0 | 0 | 0 | 0 | |
| 16 | Transaction | 0 | 0 | 1 | 0 | 1 |
| 17 | Integer | 1000 | 7 | 0 | 0 | |
| 18 | Integer | 2 | 8 | 0 | 0 | |
| 19 | Integer | 1 | 9 | 0 | 0 | |
| 20 | Goto | 0 | 1 | 0 | 0 |
Open it in the EXPLAIN visualizer →
Also in this program: Add, Column, Divide, Goto, Halt, Init, Integer, Multiply, Next, OpenRead, Remainder, ResultRow, Rewind, Transaction.
What the SQLite documentation says
Subtract the value in register P1 from the value in register P2 and store the result in register P3. If either input is NULL, the result is NULL.
From sqlite.org's list of opcodes for SQLite 3.54.1, in the public domain. Opcodes are not a stable interface and change between releases.