mysql - show sum per time period and sum per entire time span -


i have product sells monthly , have user's email

i want see total sum purchased per month per email.

also total amount purchased per email months combined

try :

i understand question this

     select  email,sum(amount),'2' ord (       select email,sum(amount) amount ,month(d1) t1 group       month(d1),email) t group email        union         select email,sum(amount) amount,      '1' ord t1 group month(d1),email       order ord 

this query return first show sum of amount per month , email after show sum of amount per email


Comments

Popular posts from this blog

jQuery Mobile app not scrolling in Firefox -

c++ - How to add Crypto++ library to Qt project -

php array slice every 2th rule -