select
    a.entity_id,
    a.attribute_value as policy_number,
    b.attribute_value as inception,
    c.attribute_value as expiry,
    d.attribute_value as cancellation,
    e.attribute_value as premium
from
    (
        select
             entity_id,
             attribute_value
        from
             entity x
             join
             attribute y
             on
                 x.entity_type = 'policy' and
                 y.attribute_type = 'policy_number' and
                 x.id = y.entity_id
    ) a 
    left outer join
    (
        select
             entity_id,
             attribute_value
        from
             entity x
             join
             attribute y
             on
                 x.entity_type = 'policy' and
                 y.attribute_type = 'inception' and
                 x.id = y.entity_id
    ) b 
    on a.entity_id = b.entity_id
    left outer join
    (
        select
             entity_id,
             attribute_value
        from
             entity x
             join
             attribute y
             on
                 x.entity_type = 'policy' and
                 y.attribute_type = 'expiry' and
                 x.id = y.entity_id
    ) c 
    on a.entity_id = c.entity_id
    left outer join
    (
        select
             entity_id,
             attribute_value
        from
             entity x
             join
             attribute y
             on
                 x.entity_type = 'policy' and
                 y.attribute_type = 'cancellation' and
                 x.id = y.entity_id
    ) d 
    on a.entity_id = d.entity_id
    left outer join
    (
        select
             entity_id,
             attribute_value
        from
             entity x
             join
             attribute y
             on
                 x.entity_type = 'policy' and
                 y.attribute_type = 'premium' and
                 x.id = y.entity_id
    ) e 
    on a.entity_id = e.entity_id;
