0

I made a Select on Sqlite3 for my QTableWidget, but when it executes it gets this

(E.VALOR_VENDA-E.VALOR_CUSTO) the result in the table is = "3...."

and in pure SQL it is correct = "3.57"

VALOR_VENDA = 5.87
VALOR_CUSTO = 2.3

Does anyone know why? I tried to correct but nothing has changed.

enter image description here

        query = """SELECT E.CODBARRA, E.PRODUTO, 
                          C.CATEGORIA, E.ESTOQUE, 
                          E.ESTOQUE_MIN, E.VALOR_CUSTO, 
                          E.VALOR_VENDA, (E.VALOR_VENDA-E.VALOR_CUSTO) AS "LUCRO", 
                          F.FORNECEDOR 
                          FROM ESTOQUE E 
                          INNER JOIN FORNECEDOR F
                          ON E.ID_FORNECEDOR = F.IDFORNECEDOR
                          INNER JOIN CATEGORIA C
                          ON E.ID_CATEGORIA = C.IDCATEGORIA
                          ORDER BY E.PRODUTO"""
eyllanesc
  • 235,170
  • 19
  • 170
  • 241

2 Answers2

0

Work with Printf

printf("%.2f",E.VALOR_VENDA-E.VALOR_CUSTO)

0

Seems a sqlite issue instead of python ...

The simple raise and down trick should work.

laoyb
  • 99
  • 2
  • 8