By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
CREATE TABLE tbl_fileStatus (
`f_id` INTEGER,
`f_bankid` INTEGER,
`f_filestatus` INTEGER
);
INSERT INTO tbl_fileStatus
(`f_id`, `f_bankid`, `f_filestatus`)
VALUES
('1', '1', '1'),
('2', '2', '1'),
('3', '2', '2'),
('4', '1', '2'),
('5', '1', '3'),
('6', '3', '2'),
('7', '3', '3');
SELECT
SUM(f_filestatus = 1) AS tcount1,
SUM(f_filestatus = 2) AS tcount2,
SUM(f_filestatus = 3) AS tcount3
FROM (
SELECT t.f_bankid, t.f_filestatus
FROM tbl_fileStatus t
WHERE t.f_id = (SELECT f_id FROM tbl_fileStatus WHERE f_bankid = t.f_bankid ORDER BY f_id DESC LIMIT 1)
) t
tcount1 | tcount2 | tcount3 |
---|---|---|
0 | 1 | 2 |