MySQL Forums
Forum List  »  Newbie

Need guidance on SQL Query
Posted by: John vianny
Date: March 18, 2022 04:32AM

Hi Everyone,

I am having an table with values like this below one.

Col1 Col2 Col3 Col4 col5

1 John ABC 10 20
1 John AED 52 15
1 John ABC 12 10
1 John AED 20 5
1 John ABC 10 5
2 Mark DDD 42 8
2 Mark BBB 10 5
3 Ben EEE 8 2
3 Ben FFF 1 1
3 Ben EEE 2 3


I want to group them in the following manner

col1 col2 col3 col4 col5
1 John ABC 32 35
1 John AED 72 20
2 Mark DDD 42 8
2 Mark BBB 10 5
3 Ben EEE 10 5
3 Ben FFF 1 1


I used the 'select col1,col2,col3,SUM(col4),SUM(col5) from table where [some condition] group by col3'

I am getting error. Can somebody help on this?


Thanks,

Options: ReplyQuote


Subject
Written By
Posted
Need guidance on SQL Query
March 18, 2022 04:32AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.