Skip to content
Advertisement

SQL result from table a but name from table b

My request is quiet simple however I can’t find it (maybe I can’t goolge correctly). I have Table A and Table B

Table A:

ID length
1 50
2 45
2 20

and Table B

ID name
1 apple
2 orange

I want to get the sum of all lengths of Table A with unique ID but with Table B’s names

Name length
apple 50
orange 65

I tried the following:

I have a feeling i made it more complicated than it has to be.

Advertisement

Answer

You don’t need a subquery:

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement