Matthieu Solle Posted May 21, 2021 Share Posted May 21, 2021 hi everybody, i would like to merge rows that have the same value. Otherwise, do the sum for the same values. For exemple, I've got two colums : - fruit -price if there is same values in row in fruit column, i want to merge them and to sum the values prices corresponding to the fruit column I will want to merge the rows with the same value in the fruit column and add the corresponding values in the price column into a single box. Basically, group a value if the fruits are the same. I hope i was clear. thank you in advance. Link to comment Share on other sites More sharing options...
Donald Johnson Posted May 21, 2021 Share Posted May 21, 2021 In the SQL Query, you can specify a 'GROUP BY' clause. What TIBCO Product are you asking this about But this query, below, is illegal now in the current versions of MySql. The 2nd select expression, f.price, is a non-aggregate. which price SELECT f.name, f.price FROM fruit_table f GROUP BY f.name Each expression needs to either be referenced in the GROUP BY clause, or used in an aggregate function, as below: SELECT f.name, SUM(f.price) FROM fruit_table f GROUP BY f.name MySQL 8.0 Reference Manual Aggregate Function Descriptions MySQL Handling of GROUP BY Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now