简体   繁体   中英

Sum columns in Sqlite3

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.

在此处输入图像描述

        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"""

Work with Printf

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

Seems a sqlite issue instead of python...

The simple raise and down trick should work.

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