Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL - Add up column value singletable

I have a table Like This

Id|purchase_date | Purchase_price
1 |02-May-17     |$10.00
2 |02-May-17     |$20.00
3 |02-May-17     |$30.00

I want to write a query where the sum of all purchase_price will calculated on the basis of purchase_date. Can Someone Please suggest the query?

like image 806
Askit Raina Avatar asked Aug 16 '26 19:08

Askit Raina


1 Answers

You can try this with groupby clause

select sum(replace(Purchase_price, '$', '')) as total from tbl group by purchase_date

enter image description here

like image 195
Sunny Khatri Avatar answered Aug 18 '26 09:08

Sunny Khatri