SQL sentence

                     select d.id as ValueId,
                         d.domain_code as DomainCode,
                         ls.value_type as ValueType, 
                     case when v.key_code is null then d.domain_code
                          when length(v.key_code)>0 then ls.key_code
                     end  as KeyCode     ,
                     case when  v.row_key is null  then '1'
                          when  length(v.row_key)>0  then v.row_key
                     end as RowKey,
                     v.value as value,
                     d.domain_value_type as DomainType
                      from                         
                          eia_draft_domain_topic dt left join  eia_draft_domain d
                          on dt.draft_domain_code = d.domain_code left join eia_draft_list ls
                          on d.domain_code=ls.domain_code left join eia_draft_values v
                          on v.domain_code = d.domain_code
                          and v.topic_code=dt.draft_topic_code
                          and v.draft_project_id=406,
                          eia_draft_project_topic pt,
                          eia_draft_topic t
                      WHERE  
                          pt.topic_code = t.topic_code
                      and dt.draft_topic_code=t.topic_code
                      and t.topic_code = '01'
                      and pt.draft_project_id=406

你可能感兴趣的:(sql)