Jump to content
Seja Membro VIP - Remova Banners de Propagandas, Tenha Liberado Qualquer Download, Além de Acessos em Áreas Exclusivas!! ×

Recommended Posts


  • Topic Count:  31
  • Topics Per Day:  0.01
  • Content Count:  54
  • Content Per Day:  0.01
  • Reputation:   0
  • Achievement Points:  582
  • Solved Content:  0
  • Days Won:  0
  • Status:  Offline
  • Age:  36

Posted

Bom dia, pessoal.

Em qual relacionamento das tabelas de RH posso obter o nome da pai, do pai e os dados do cônjuge de um funcionário.

 

At.te,

Juliana Paixão

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic


  • Topic Count:  926
  • Topics Per Day:  0.13
  • Content Count:  9,097
  • Content Per Day:  1.31
  • Reputation:   376
  • Achievement Points:  109,102
  • Solved Content:  0
  • Days Won:  232
  • Status:  Offline
  • Age:  53
  • Device:  Windows

Posted

Juliana,

boa tarde.

Estes dados estão na tabela de Dependentes. Você deverá buscar os dependentes com GRAUPARENTESCO 5, 6 e 7.
5 - Cônjuge
6 - Pai
7 - Mãe

Então, seria algo como:

Select  Pfunc.Chapa,
        Pfunc.Nome,
        Case GRAUPARENTESCO When '5' Then 'Cônjuge'
                                When '6' Then 'Pai'
                                When '7' Then 'Mãe'
        End as GrauParentesco,
        Pfdepend.Nome
From Pfunc
Left Join Pfdepend on (PFunc.Chapa=PFDepend.Chapa and Pfunc.CodColigada=PFDepend.CodColigada)
Where Pfunc.CodColigada = '1' and (GRAUPARENTESCO in ('5','6','7') or GRAUPARENTESCO is null)
order by Pfunc.Chapa, GrauParentesco

ou

Select  Pfunc.Chapa,
        Pfunc.Nome,
        Pai.Nome as NomePai,
        Mae.Nome as NomeMae,
        Conjuge.Nome as NomeConjuge
From Pfunc
Left Join Pfdepend Pai on (PFunc.Chapa=Pai.Chapa and Pfunc.CodColigada=Pai.CodColigada and Pai.GRAUPARENTESCO ='6')
Left Join Pfdepend Mae on (PFunc.Chapa=Mae.Chapa and Pfunc.CodColigada=Mae.CodColigada and Mae.GRAUPARENTESCO = '7')
Left Join Pfdepend Conjuge on (PFunc.Chapa=Conjuge.Chapa and Pfunc.CodColigada=Conjuge.CodColigada and Conjuge.GRAUPARENTESCO = '5')
Where Pfunc.CodColigada = '1'
Order by Pfunc.Chapa

 


  • Topic Count:  31
  • Topics Per Day:  0.01
  • Content Count:  54
  • Content Per Day:  0.01
  • Reputation:   0
  • Achievement Points:  582
  • Solved Content:  0
  • Days Won:  0
  • Status:  Offline
  • Age:  36

Posted

Obrigada, Jair.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.