Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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

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.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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;
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading