0

Here is my table

a  |  b  |  c
1     2     3
1     2     3
1     2     3

Is it possible to write select, which will return me something like this:

select * from table1 where a = 1

a  |  b  |  c
1     2     9 

In the last column I want to get SUM of all elements in column c

Dmitry
  • 3
  • 3

1 Answers1

0

Where does the a and b come from in your results? What if there's a row (42, 7, 12)? Group by allows you to group the results based on other columns, which can then be included in the results as the group "keys". If you don't group, you can only use aggregate functions in the results.

If all you want is to get the sum of c, why not just select sum(c) from table1 where a = 1;. You can't select a or b, since there can be multiple different values for a and b.

Luaan
  • 62,244
  • 7
  • 97
  • 116