Python Forum
Python tKinter sQL. How to add a column of values?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python tKinter sQL. How to add a column of values?
#1
Hello,

I'm trying to calculate the total of a column of values using an sQL DB.
The values are generated using a query.

I have an Orders table: within that the 'Quantity' column is multiplied by the 'Price' column to create a 'Totals' column. I am joining 2 tables to gain the values.
Therefore, when I use the SELECT SUM(Totals) command it tells me that there is no column called Totals.

My query is as follows:

c = myshop_db.execute('''SELECT Orders.Cust_Num, Orders.Order_Date, Orders.Prod_Num, Products.Prod_Name, Orders.Prod_Qty, Products.Prod_Cost, Orders.Prod_Qty * Products.Prod_Cost as Total
    FROM Orders
    INNER JOIN Products
    ON Orders.Prod_Num = Products.Prod_Num
    WHERE Orders.Order_Num = ?''', num)
Therefore, it is 'Total' I need to calculate.

Further to this, can I display this new value using the same 'Tree' 'Frame' that I am using to display this query?
I really hope this can be done, obviously I'll be very grateful for any suggestions or alternatives.

Many thanks in advance,
Dewi :)
Reply


Messages In This Thread
Python tKinter sQL. How to add a column of values? - by dewijones67 - Feb-12-2019, 09:32 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [Tkinter] Tkinter delete values in Entries, when I'm changing the Frame robertoCarlos 11 9,598 Jul-29-2020, 07:13 PM
Last Post: deanhystad
  [Tkinter] Problems to display Web Scraping values in Tkinter Lucas_Ribeiro 0 2,054 May-07-2020, 12:36 AM
Last Post: Lucas_Ribeiro
  [Tkinter] Tkinter adding entry values scratchmyhead 1 3,016 May-04-2020, 05:21 AM
Last Post: Yoriz
  [Tkinter] Unable to Obtain values from one Tkinter Program into another nilaybnrj 1 3,115 Aug-24-2018, 01:24 PM
Last Post: Gribouillis

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020