This will do it for you whether you have no records in the table or have records. When it gets to 10, it will show it as: NP-0010. When it gets to 112, it will show it as: NP-0112. When it gets to 1001, it shows it as: NP-1001, etc.
Sub NUMEROPEDIDO
Dim strID As String = SQL.ExecQuerySingleResult($"SELECT max(rowid) FROM pedidos"$)
If strID=Null Then
strID = "NP-0001"
Else
strID = SQL.ExecQuerySingleResult($"SELECT 'NP-' || printf('%04i', max(rowid)+1) FROM pedidos"$)
End If
Log(strID)
End Sub