This is below data in Table2
ID2 | Count2
-----------+-----------
1345653 5
534140349 5
682527813 4
687612723 3
704318001 5
This is my below data in Table1
ID1 | Count1
-----------+-----------
1345653 4
704318001 4
- If you see the above table this
1345653in Table2 has5 countbut in Table1 it has4 count, In the same way this ID704318001in Table2 has5 countbut in Table1 it has4 count. - And also one more thing I need to show, I don’t know whether it is possible to do it or not. I want to show the sum of each column also in the end, like sum of Count2 column in the end and sum of Count1 column in the end.
So I need to show like this in the Output. I have my working query for the first part, but I am not sure how to work on second part.
ID Count2 Count1
-----------------------------------
1345653 5 4
534140349 5 0
682527813 4 0
687612723 3 0
704318001 5 4
22 8
Is this possible in sql? If Yes, how can I achieve that?
I have created the SQL fiddle in which only the count thing is working(means first part), And I am not sure how to add the sum of each column feature in that SQL query.
Will it work for you?
It’s mysql syntax, but most RDMS support
ROLLUPwith a small difference in syntax