简体   繁体   中英

Merging and Adding MySQL Rows?

Here's an example of what's in my table:

id, domain, revenue, traffic
1, example.com, 0.01, 500
2, example.com, 0.01, 250
3, stackoverflow.com, 0.01, 400
4, example.com, 0.01, 350
5, stackoverflow.com, 0.01, 500

I basically want to select/merge rows based upon the domain column. For example, I'd want to output this from the above:

domain, revenue, traffic
example.com, 0.03, 1100
stackoverflow.com, 0.02, 900

something like this:

Select domain, sum(revenue),sum(traffic) from table group by domain;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM