[SOLVED] How to sum where there's a condition from with different column

Issue

Here’s the table

IP PID Aging
192.168.01 6891 3
192.168.01 6892 2
192.168.01 6893 1
192.168.01 6891 5

How to sum only row that has same IP and PID.
(I want to sum aging column that only has the same IP and PID for example see the table that already bolded).

I already done several things using WHERE clause but there’s no result that I wanted.

Thanks.

Solution

If I understand correctly, you only need to aggregate by the IP and PID:

SELECT ID, PID, SUM(Aging) Aging
FROM yourTable
GROUP BY ID, PID;

Answered By – Tim Biegeleisen

Answer Checked By – Mary Flores (BugsFixing Volunteer)

Leave a Reply

Your email address will not be published.