Duvida como montar query

SQL Server

11/02/2010

Bom dia,

Tenho uma tabela projeto e uma tabela tarefa(São as tarefas do projeto), gostaria de montar um query para trazer todos projetos que estão em aberto ou seja que tenha uma tarefa que não esteja com status fechado pensei em fazer assim:

select DISTINCT cod_projeto, descricao_projeto
left join tarefa
on tarefa.cod_projeto = projeto.cod_projeto
left join status
on status.cod_status = tarefa.cod_status
where tarefa.cod_status != 1

alguem sabe como fazer ? ...

1 = status fechado


Alexandre_fsa

Alexandre_fsa

Curtidas 0

Respostas

Riqueciano Soares

Riqueciano Soares

11/02/2010


select DISTINCT cod_projeto, descricao_projeto
left join tarefa
on tarefa.cod_projeto = projeto.cod_projeto
left join status
on status.cod_status = tarefa.cod_status
where tarefa.cod_status != 1

alguem sabe como fazer ? ...

1 = status fechado

--mudei paticamente nada-------------------------------------------------------

select DISTINCT cod_projeto, descricao_projeto
from tarefa
    inner join projeto
      on tarefa .cod_projeto = projeto.cod_projeto
    inner join status
      on status.cod_status = tarefa.cod_status
where tarefa.cod_status != 1


espero ter ajudado
GOSTEI 0
POSTAR