I am really new to PostgreSQL using version is 9.3.
Well I have the following table with some records:
Example:
create table tst
(
cola varchar(10),
colc varchar(10)
)
insert into tst values('101','A1');
insert into tst values('101','A2');
insert into tst values('201','A3');
insert into tst values('301','A4');
insert into tst values('401','A1');
insert into tst values('101','A6');
insert into tst values('201','A1');
insert into tst values('201','A5'); 
Note: Now I want to show only that records in which cola belongs to colc's values. If the user pass the colc values as a parameter to function then it has to match the exact value of colc belongs to which cola value.
Expected Result:
If the user pass A1,A2,A6 then the result should be:
cola   A1   A2   A6
--------------------
101    1    1    1
Note: In the above result the record 101 appears because it belongs to A1,A2,A6 not other values. 201 not appear because that belongs to A1,A3 and A5 also.
If the user pass A1 then the result should be:
cola   A1 
----------
401    1  
Note: In the above result the record 401 appears because it belongs to only A1. 
I am not getting how to write crosstab within function for this scenario.
 
     
    