SQLite: Get Total/Sum of Column

I am using SQLite and am trying to return the total of one column buy_price in the column TOTAL while at the same time returning all of the data. I do not want/need to group the data as I need to have the data in each returned row.

id    date       pool_name    pool_id    buy_price  TOTAL
 1    09/01/12   azp          5          20
 2    09/02/12   mmp          6          10
 3    09/03/12   pbp          4          5
 4    09/04/12   azp          7          20
 5    09/05/12   nyp          8          5             60

When I include something like SUM(buy_price) as TOTAL it only returns one row. I need all rows returned along with the total of all buy_price entries.


It sounds like this is what you are looking for:

select id,
  (select sum(buy_price) from yourtable) total
from yourtable

see SQL Fiddle with Demo

Select * from yourtable
select 'Total',
  ' ',
  ' ',
  ' ',
from yourtable

you can add a row on the bottom like this instead of adding a new column...

Need Your Help

ASP.NET Core MVC : How to get raw JSON bound to a string without a type?

c# asp.net-mvc asp.net-web-api asp.net-core-mvc

Similar to this old question about prior ASP.NET versions, I want to get the request body of an HTTP POST to be bound to a string. It seems that the method binds, but that value is null, when ASP.NET

What needs to be overridden in a struct to ensure equality operates properly?

c# .net struct operators equals-operator

As the title says: do I need to override the == operator? how about the .Equals() method? Anything I'm missing?