none
Adicionar um select numa query no SQL RRS feed

  • Pergunta

  • Srs,

    Não consigo adicionar esse select abaixo  na query no final da página, tenho que usar JOIN:

     

    select custom_field_master.id, custom_field_master.domain_value, count(d.id)
    from (select distinct dv.id, dv.domain_value, dv.sequence from custom_field_info info
    join domain_values_category cat on info.column_values_fk = cat.id
    join domain_values dv on dv.category_fk = cat.id
    join domain_values entityTypeDv on info.entity_type_fk = entityTypeDv.id
    where entityTypeDv.domain_id = 'ENTITY_TYPE_DEFECT'  and info.column_name = 'Key2' and info.project_fk = 2652 ) as custom_field_master
    left outer join custom_fields cf on cf.key2 = custom_field_master.id
    left outer join (select def.* from defect def
    join build b on def.found_in_build_fk = b.id
    join release r on b.release_fk = r.id
    where  def.draft_flag='N') as d on cf.defect_fk = d.id


    group by custom_field_master.id, custom_field_master.domain_value, custom_field_master.sequence
    order by custom_field_master.sequence

     

     

    Query:

    select d.id as DEFECT_ID
    , d.defect_id
    , status.domain_value  as DEFECT_STATUS
    , priorDV.domain_value as DEFECT_PRIORITY
    , sev.domain_value as DEFECT_SEVERITY


    , r.name as APLICATIVO
    , fb.name as Build
    from build fb
    join release as r on r.id=fb.release_fk

    left join defect as d  on fb.id = d.found_in_build_fk 
    left join (select dv.* from domain_values dv join domain_values_category dc on dv.category_fk = dc.id
    where dc.domain_category_id = 'DEF_STATUS' and (dv.project_fk = 2652 or dv.project_fk is null)) as status on status.id = d.status_fk

    left join (select dv.* from domain_values dv
    join domain_values_category dc on dv.category_fk = dc.id
    where dc.domain_category_id = 'DEF_PRIORITY' and dv.project_fk = 2652) as priorDV on priorDV.id = d.priority_fk

    left join (select dv.* from domain_values dv
    join domain_values_category dc on dv.category_fk = dc.id
    where dc.domain_category_id = 'DEF_SEVERITY' and dv.project_fk = 2652) as sev on sev.id = d.severity_fk

     

    where d.draft_flag = 'N' --and d.id = 46741 
    and r.project_fk = 2652

    group bY  fb.id, fb.name, status.domain_value, status.sequence, priorDV.domain_value, r.name, d.id, sev.domain_value, d.defect_id
    order by  d.id

    quinta-feira, 29 de setembro de 2011 16:57

Todas as Respostas

  • MrDiniz,

    Você esta querendo fazer um Union?

    O SQL Server esta retornando alguma mensagem de erro?


    Pedro Antonio Galvão Junior [MVP | Microsoft Evangelist | Microsoft Partner | Engenheiro de Softwares | Especialista em Banco de Dados | SorBR.Net | Professor Universitário | MSIT.com]
    sábado, 1 de outubro de 2011 18:57