0

I'm trying to have sqlite automatically do the calculation below for each column. I used the following line but not getting the intended result[see picture]

Any help is appreciated.

SELECT 
    shares, current_price, 
    shares * current_price as 'Total' 
FROM portfolio

enter image description here

0

The '$' in the current_price column indicates it is treating current_price as a string. From the Datatypes in SQLite Version 3 doc:

SQLite uses a more general dynamic type system. In SQLite, the datatype of a value is associated with the value itself, not with its container.

The heart of the problem is the portfolio insert.

2
  • Thanks as always! If you don't mind me asking, are you a cs50 volunteer?
    – Salamit
    Jul 8 '17 at 11:30
  • You're welcome. No, this is just a hobby to keep on top of my troubleshooting/debugging game :) Jul 8 '17 at 15:17

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .