add batch remove batch split batch comment selection show hidden batches hide batch highlight batch
db<>fiddle
donate feedback about
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');
Records: 7  Duplicates: 0  Warnings: 0
SELECT COUNT(DISTINCT f_bankid) AS tcount
FROM tbl_fileStatus t
WHERE 1 = (SELECT f_filestatus FROM tbl_fileStatus WHERE f_bankid = t.f_bankid ORDER BY f_id DESC LIMIT 1)
tcount
0
SELECT COUNT(DISTINCT f_bankid) AS tcount
FROM tbl_fileStatus t
WHERE 2 = (SELECT f_filestatus FROM tbl_fileStatus WHERE f_bankid = t.f_bankid ORDER BY f_id DESC LIMIT 1)
tcount
1
SELECT COUNT(DISTINCT f_bankid) AS tcount
FROM tbl_fileStatus t
WHERE 3 = (SELECT f_filestatus FROM tbl_fileStatus WHERE f_bankid = t.f_bankid ORDER BY f_id DESC LIMIT 1)
tcount
2