I want to create and run a view(from the survey) by SQL in odoo9. I meet a dimension problem. My query result should be one-row record, not multi-row record. Does somebody know how to solve this problem?
select v.id, o.year,
(case when (v.code = 'OHS001Q01F01') then v.value else null end) as ohs001q01f01,
(case when (v.code = 'OHS001Q01F02') then v.value else null end) as ohs001q01f02,
(case when (v.code = 'OHS001Q01F03') then v.value else null end) as ohs001q01f03,
(case when (v.code = 'OHS001Q02F01') then v.value else null end) as ohs001q02f01,
(case when (v.code = 'OHS001Q02F02') then v.value else null end) as ohs001q02f02,
(case when (v.code = 'OHS001Q02F03') then v.value else null end) as ohs001q02f03,
(case when (v.code = 'OHS001Q02F04') then v.value else null end) as ohs001q02f04,
(case when (v.code = 'OHS001Q02F05') then v.value else null end) as ohs001q02f05,
(case when (v.code = 'OHS001Q02F06') then v.value else null end) as ohs001q02f06,
(case when (v.code = 'OHS001Q02F07') then v.value else null end) as ohs001q02f07,
(case when (v.code = 'OHS001Q02F08') then v.value else null end) as ohs001q02f08,
(case when (v.code = 'OHS001Q03F01') then v.value else null end) as ohs001q03f01
,o.hre_empbas_id
from
ohs_survey o inner join dynamic_survey_record c
on o.year = '2019' and o.hre_empbas_id=24699 and o.survey_record_id = c.id
inner join dynamic_survey_value v
on c.id = v.record_id
inner join dynamic_survey ds
on ds.code = 'OHS001' and c.survey_id = ds.id