Nov-15-2019, 03:27 PM
Hello,
This is a simple query where I need to display a quantity, and the percentage it represents.
I don't know if it's a Python or SQLite issue, but for some reason, the percentage column only displays "0.00" for all the rows:
Thank you.
This is a simple query where I need to display a quantity, and the percentage it represents.
I don't know if it's a Python or SQLite issue, but for some reason, the percentage column only displays "0.00" for all the rows:
cur.execute("SELECT NUMBER,1.0 * NUMBER / (SELECT SUM(NUMBER) FROM MyTable) AS PERCENTAGE FROM MyTable") rows = cur.fetchall() for row in rows: output = "{}\t{:.2f}".format(row['NUMBER'],row['PERCENTAGE']) print(output)Can someone spot the error?
Thank you.