2011/5/19 Adarsh Sharma <adarsh.sharma@xxxxxxxxxx>: > Dear all, > > I am not able to insert data into a table in horizontal form. > > The data is in below form : > > A show a small set of data :- > > c_id     f_name   Â Â f_value > 2       k1  Â Â Â Â Â   v1 > 2       k2      Â v2 > 2       k3      Â v3 > 2       k4      Â v4 > 3       a1        b1 > 3       a2  Â Â Â Â Â Â Â b2 > 3       a3  Â Â Â Â Â Â Â b3 > 3       a4  Â Â Â Â Â Â Â b4 > 3       a5  Â Â Â Â Â Â Â b5 > 1       c1        d1 > 1       c2   Â     d2 > 3       a1        e1 > 3      Â a2 Â Â Â Â Â Â Â e2 > 3       a3        e3 > 3       a4        e4 > 3       a5        e5 > > Now i want to show the above data in horizontal form as per c_id , fore.g if > a user enters c_id 3 then output is : > > c_id     a1    a2     a3   Â a4   Â a5 > 3       b1    b2    b3  Â b4   b5 > 3       e1    e2  Â  e3    e4 >  e5 > > i.e f_name entries became the columns of the table & f_value become the rows > > > I research on crosstab function but i don'e think it is useful because we > have to give column names in the command. > I want to show it dynamically . I try to create a procedure & also attach > it. > > A user enters only c_id & output is shown fore.g if a user enters c_id 1 > then output is > > c_id     c1     c2 > 1       d1     d2 > > I show the data in simple way bt there r 10000 of rows & 100 of c_id's. > > > Please let me know if it is possible or any information is required. > Something like this? http://wiki.postgresql.org/wiki/Pivot_query -- --        Emanuel Calvo        Helpame.com -- Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general