表数据(daydetail)
date cnt price totalcnt totalprint
20170101 1 10 1 10
20170102 1 10 2 20
20170103 1 10 3 30
20170104 2 20 5 50
其中 totalcnt totalprice 为合计值。这2个值 怎样动态算出来
每一天都是之前的合计
一个sql能实现吗?
类似于 select date,cnt, price (select sum(cnt) totalcnt,sum(price) totalprice from daydetail where *****************) from daydetail