Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in SQL by (2.6k points)

I have a table with 4 columns (W,X,Y,Z). I want to select some rows from the table and then MySQL to return a single row having the values added on each column...

 

   W X Y Z

1. 2 2 2 2

2. 4 4 4 4

3. 6 7 8 9

MySql should return in this case, if I select all the four rows:

 

   W   X   Y  Z

1. 12  13 14  15

1 Answer

0 votes
by (7.2k points)

I can sum elements of a column in SQL. Using this code you will get your solutions.

select sum(W),sum(X),sum(Y),sum(Z) from mytable where id in (1,2,3,4);

Related questions

0 votes
1 answer
0 votes
1 answer
asked Dec 15, 2020 in Python by ashely (50.2k points)
0 votes
1 answer

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...