Positional value issues with PostgreSQL crosstab I am running this query:

select *
              FROM crosstab (
                $$
                  select postcode::text, indicator::int, value::float
                  from indicator_data
                  where
                    (indicator = 35 or indicator = 36 or indicator = 37 or indicator = 38 or indicator = 39 or
                    indicator = 105 or indicator = 106 or indicator = 107 or indicator = 108 or indicator = 108) and date = '2017-04-01'
                  order by 1,2
                $$)
              AS ct (
                "postcode" text,
                "one_y" float,
                "two_y" float,
                "three_y" float,
                "four_y" float,
                "five_y" float,
                "one_l" float,
                "two_l" float,
                "three_l" float,
                "four_l" float,
                "five_l" float
                )


against the table:

indicator   postcode    date        value
35          NW3 3       2017-04-01  1000
105         NW3 3       2017-04-01  2
37          NW3 3       2017-04-01  2000
107         NW3 3       2017-04-01  3

postcode    one_y   two_y   three_y four_y  five_y  one_l   two_l   three_l four_l  five_l
NW3 3       1000    2000    2       3       NULL    NULL    NULL    NULL    NULL    NULL


instead of this expected result:

postcode    one_y   two_y   three_y four_y  five_y  one_l   two_l   three_l four_l  five_l
NW3 3       1000    NULL    2000    NULL    NULL    2       NULL    3       NULL    NULL


How can I fix the query to return the exact positions for the values in the temporary table like in the expected result?

UPDATE
I have added the pivotal query in this change:

select *
                  FROM crosstab (
                    $$
                      select postcode::text, indicator::int, value::float
                      from indicator_data
                      where
                        (indicator = 35 or indicator = 36 or indicator = 37 or indicator = 38 or indicator = 39 or
                        indicator = 105 or indicator = 106 or indicator = 107 or indicator = 108 or indicator = 108) and date = '2017-04-01'
                      order by 1,2
                    $$,
                    $$
                    SELECT g FROM generate_series(1,10) g
                    $$)


but it doesn't help
It's not clear to me what is the relation between one_y and indicator 35 but assuming that they have a 1 to 1 correspondence to the where part of your first query I can came up with a solution.

Clearly you need the updated two parameter version of crosstab function.
What you are missing is the right category values.

Try this as your second parameter...

select * from  (
            values  (35) , (36) ,(37) , (38) , (39) , (105) , (106) ,(107) , (108) , (109)) a


The final query would be...

select *
          FROM crosstab (
            $$
              select postcode::text, indicator::int, value::float
              from indicator_data
              where
                (indicator = 35 or indicator = 36 or indicator = 37 or indicator = 38 or indicator = 39 or
                indicator = 105 or indicator = 106 or indicator = 107 or indicator = 108 or indicator = 108) and date = '2017-04-01'
              order by 1,2
            $$,
            $$ 
            select * from  (
            values  (35) , (36) ,(37) , (38) , (39) , (105) , (106) ,(107) , (108) , (109)) a
            $$
         )
          AS ct (
            "postcode" text,
            "one_y" float,
            "two_y" float,
            "three_y" float,
            "four_y" float,
            "five_y" float,
            "one_l" float,
            "two_l" float,
            "three_l" float,
            "four_l" float,
            "five_l" float
            )


Resulting in ...

 postcode | one_y | two_y  | three_y | four_y | five_y | one_l | two_l  | three_l | four_l | five_l 
----------+-------+--------+---------+--------+--------+-------+--------+---------+--------+--------
 NW3 3    |  1000 | [null] |    2000 | [null] | [null] |     2 | [null] |       3 | [null] | [null]
(1 row)


Regards