I want to create an autoincrementable column that recognizes the type of voucher that will be issued. I have the following table:
-------------------------------------------------------------
|id | numcomprobante | tipocomprobante | iddetalleventa |
-------------------------------------------------------------
| 1 | B00-0001 | BOLETA | 1 |
| 2 | B00-0002 | BOLETA | 2 |
| 3 | F00-0001 | FACTURA | 3 |
| 4 | B00-0003 | BOLETA | 4 |
As you can see, the first two rows that are ballots are issued in incremental order, but with a prefix of letter B, like the initial of the type of voucher, however the third row restarts the number, and the letter prefix change to another letter 'F', then continue with the previous number
How could I do it with a trigger?