1

I would like to organise a table with some conditions. I need to order by id, and to add a column that make sum of the same species, with the same id (cf.bold charachter).

enter image description here

Do you have any idea ?

2
  • 1
    so... have you tried what you wrote in the title? select id, sum(number) || species group by id, species
    – JGH
    Commented Apr 30, 2020 at 13:02
  • You would still get multiple rows for different combinations of id and species attribute. It would be clearer as I wrote in my answer below. Commented Apr 30, 2020 at 13:15

1 Answer 1

0

You would not get one row per id but multiple rows for different combinations of id and species attribute.

SELECT id, species, SUM(number) FROM species_table GROUP BY id, species
2

Not the answer you're looking for? Browse other questions tagged or ask your own question.