[Solved] SQL Query for stats on table (Help in SQL query) [closed]


Below query should do the job. Names in the ADDED_BY column seem to be the reference for aggregation in both your columns.

SELECT A.ADDED_BY, A.TOTAL_RECORDS_ADDED_BY,
COUNT(B.UPDATED_BY) AS TOTAL_RECORDS_UPDATED_BY
FROM
    (SELECT ADDED_BY, COUNT(*) AS TOTAL_RECORDS_ADDED_BY
    FROM
    YOUR_TABLE
    GROUP BY ADDED_BY) A
LEFT JOIN
YOUR_TABLE B
ON A.ADDED_BY = B.UPDATED_BY
GROUP BY A.ADDED_BY, A.TOTAL_RECORDS_ADDED_BY;

solved SQL Query for stats on table (Help in SQL query) [closed]