SQLite Calculate sum outside group by -


i'm trying calculate percentage of customer has spent on total sales value. have calculated total sales value per customer using sum() , group by, after use group by, cannot differentiate total sales value , individual total each sustomer.

is there anyway around this?

i got here far , dont know next:

select c.firstname ||' '|| c.lastname 'ful name',  sum(total) 'sales value',  /*something calculate percentage*/, invoice inner join customer c on i.customerid = c.customerid  group i.customerid order sum(total) desc limit 5; 

to calculate simple sum on entire table, move independent subquery:

select ...,        sum(total) / (select sum(total) invoice) ...; 

Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -