Jump to content
Sign in to follow this  
Lidia Cesar

Sql

Recommended Posts

Tenho uma sentença SQL, onde preciso gerar um relatório de eventos.

SELECT

PFF.CHAPA

FROM

PFFINANC PFF

INNER JOIN PFUNC PF ON PF.CHAPA =PFF.CHAPA

AND PFF.CODCOLIGADA = PF.CODCOLIGADA

WHERE

PFF.CODEVENTO = '0294'

AND PFF.MESCOMP = '09'

AND PFF.ANOCOMP = '2014'

AND PF.CODFILIAL= '1'

AND PF.CODSECAO LIKE '%'

AND NROPERIODO = '1'

Preciso que esta sentença me traga o valor do evento e código da seção.

Podem me ajudar?

Share this post


Link to post
Share on other sites

Basta inserir o que está destacado em vermelho no 'select'.



SELECT


PFF.CHAPA, PFF.VALOR, PF.CODSECAO


FROM


PFFINANC PFF


INNER JOIN PFUNC PF ON PF.CHAPA =PFF.CHAPA


AND PFF.CODCOLIGADA = PF.CODCOLIGADA



WHERE


PFF.CODEVENTO = '0294'


AND PFF.MESCOMP = '09'


AND PFF.ANOCOMP = '2014'


AND PF.CODFILIAL= '1'


AND PF.CODSECAO LIKE '%'


AND NROPERIODO = '1'


Share this post


Link to post
Share on other sites

Basta inserir o que está destacado em vermelho no 'select'.

SELECT

PFF.CHAPA, PFF.VALOR, PF.CODSECAO

FROM

PFFINANC PFF

INNER JOIN PFUNC PF ON PF.CHAPA =PFF.CHAPA

AND PFF.CODCOLIGADA = PF.CODCOLIGADA

WHERE

PFF.CODEVENTO = '0294'

AND PFF.MESCOMP = '09'

AND PFF.ANOCOMP = '2014'

AND PF.CODFILIAL= '1'

AND PF.CODSECAO LIKE '%'

AND NROPERIODO = '1'

Agradeço pelo pronto atendimento.

Nesta mesma SQL pode inserir o nome da seção?

SELECT

PFF.CHAPA, PFF.VALOR, PF.CODSECAO

FROM

PFFINANC PFF

INNER JOIN PFUNC PF ON PF.CHAPA =PFF.CHAPA

AND PFF.CODCOLIGADA = PF.CODCOLIGADA

WHERE

PFF.CODEVENTO = '0294'

AND PFF.MESCOMP = '09'

AND PFF.ANOCOMP = '2014'

AND PF.CODFILIAL= '1'

AND PF.CODSECAO LIKE '%'

AND NROPERIODO = '1'

Share this post


Link to post
Share on other sites

Para trazer a seção utilize a sentença da seguinte forma:

SELECT

PFF.CHAPA, PFF.VALOR, PF.CODSECAO, PS.DESCRICAO

FROM

PFFINANC PFF

INNER JOIN PFUNC PF ON PF.CHAPA =PFF.CHAPA

AND PFF.CODCOLIGADA = PF.CODCOLIGADA

, PSECAO PS

WHERE

PFF.CODEVENTO = '0294'

AND PF.CODSECAO = PS.CODIGO

AND PFF.MESCOMP = '09'

AND PFF.ANOCOMP = '2014'

AND PF.CODFILIAL= '1'

AND PF.CODSECAO LIKE '%'

AND NROPERIODO = '1'

Share this post


Link to post
Share on other sites

Olá Lidia!

Ajustei a sentença para trazer mais informações, caso não necessite basta apagar do select... Espero que ajude!

select
sec.descricao as nomeSecao
, fnc.nome as nomeFuncao
, fun.chapa
, fun.nome as nomeColaborador
, fun.salario
, fic.codEvento as codigoEvento
, eve.descricao as nomeEvento
, fic.valor

from
pFunc fun (noLock)

inner join pFfinanc fic (noLock)
on ((fun.codColigada = fic.codColigada)
and (fun.chapa = fic.chapa))

inner join pEvento eve (noLock)
on ((fic.codColigada = eve.codColigada)
and (fic.codEvento = eve.codigo))

inner join pSecao sec (noLock)
on ((fun.codColigada = sec.codColigada)
and (fun.codSecao = sec.codigo))

inner join pFuncao fnc (noLock)
on ((fun.codColigada = fnc.codColigada)
and (fun.codFuncao = fnc.codigo))

where
fun.codColigada = 1
and fun.codFilial = 1
and sec.descricao like '%'
and fic.nroPeriodo = 1
and fic.codEvento = '0294'
and fic.mesComp = 9
and fic.anoComp = 2014

Se precisar de algo mais, pode solicitar! Se ajudou posta aqui e encerra o tópico!

Abraços!

Share this post


Link to post
Share on other sites

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.

Sign in to follow this  

×
×
  • Create New...

Important Information

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