A PostgreSQL table with data in the format
the table name is tbl1 tbl1
id -- RCODE -- CCODE -- LDATA
1 123 50 p1
2 124 51 p2
3 126 50 p3
....................... ......... ..... .
23 116 56 p3
24 126 50 p9
25 126 50 p3
26 136 56 p5
27 126 50 p3
28 146 52 p7
My problem is how to find the count of CCODE =50
from last 7 records of the db having RCODE =126