Multiple COUNT select from same table

I fixed the issue in this way:

SELECT R.id_request,
    (SELECT COUNT(*) FROM Flow F 
        WHERE F.id_request = R.id_request AND processStatus = 1) AS flowTotal,
    (SELECT COUNT(*) FROM Flow F 
        WHERE F.id_request = R.id_request AND processStatus = 2) AS flowApproved
FROM Request R
Tagged

Leave a Reply