Jump to content
Marcelo Conceição

Cubo de Horas Extras

Recommended Posts

Oi pessoal tenho um CUBO com a seguinte sentença:

SELECT PFUNC.NOME,UPPER(PSECAO.DESCRICAO) AS DEPART,

UPPER(PTPFUNC.DESCRICAO) AS TIPO,UPPER(PCODSITUACAO.DESCRICAO) AS SITUACAO,

DATEPART(DAY,AAFHTFUN.DATA) DIA,

CASE

WHEN DATEPART(MONTH,AAFHTFUN.DATA)='1' THEN '01-JAN'

WHEN DATEPART(MONTH,AAFHTFUN.DATA)='2' THEN '02-FEV'

WHEN DATEPART(MONTH,AAFHTFUN.DATA)='3' THEN '03-MAR'

WHEN DATEPART(MONTH,AAFHTFUN.DATA)='4' THEN '04-ABR'

WHEN DATEPART(MONTH,AAFHTFUN.DATA)='5' THEN '05-MAI'

WHEN DATEPART(MONTH,AAFHTFUN.DATA)='6' THEN '06-JUN'

WHEN DATEPART(MONTH,AAFHTFUN.DATA)='7' THEN '07-JUL'

WHEN DATEPART(MONTH,AAFHTFUN.DATA)='8' THEN '08-AGO'

WHEN DATEPART(MONTH,AAFHTFUN.DATA)='9' THEN '09-SET'

WHEN DATEPART(MONTH,AAFHTFUN.DATA)='10' THEN '10-OUT'

WHEN DATEPART(MONTH,AAFHTFUN.DATA)='11' THEN '11-NOV'

WHEN DATEPART(MONTH,AAFHTFUN.DATA)='12' THEN '12-DEZ'

END AS MES,

CASE

WHEN SUM(AAFHTFUN.EXTRAEXECUTADO)/60 BETWEEN 00 AND 40 THEN '1- VERDE (ATÉ 40H)'

WHEN SUM(AAFHTFUN.EXTRAEXECUTADO)/60 BETWEEN 41 AND 45 THEN '2- AMARELO (DE 41H ATÉ 45H)'

WHEN SUM(AAFHTFUN.EXTRAEXECUTADO)/60 BETWEEN 46 AND 99 THEN '3- VERMELHO (MAIOR 45H)'

ELSE NULL

END STATUS,

DATEPART(YEAR,AAFHTFUN.DATA) ANO,

SUM(AAFHTFUN.EXTRAEXECUTADO)/60 QTD_HORA

FROM AAFHTFUN(NOLOCK),PFUNC(NOLOCK),PSECAO(NOLOCK),PTPFUNC(NOLOCK),PCODSITUACAO(NOLOCK)

WHERE AAFHTFUN.CODCOLIGADA=PFUNC.CODCOLIGADA

AND AAFHTFUN.CHAPA=PFUNC.CHAPA

AND PFUNC.CODCOLIGADA=PSECAO.CODCOLIGADA

AND PFUNC.CODSECAO=PSECAO.CODIGO

AND PFUNC.CODTIPO=PTPFUNC.CODCLIENTE

AND PFUNC.CODSITUACAO=PCODSITUACAO.CODCLIENTE

GROUP BY PFUNC.NOME,PSECAO.DESCRICAO,

DATEPART(DAY,AAFHTFUN.DATA),DATEPART(MONTH,AAFHTFUN.DATA),

DATEPART(YEAR,AAFHTFUN.DATA),PTPFUNC.DESCRICAO,PCODSITUACAO.DESCRICAO

O problema é que o "STATUS" não está funcionando.

Alguém pode mi ajudar?

Share this post


Link to post
Share on other sites

Não funcionou. O problema é que está aparecendo apenas o "status" = 1- VERDE (ATÉ 40H). Porém, existe pessoas com mais de 40h extras.

Marcelo,

Sei que esse Post é antigo, porém você conseguiu resolver esse problema?

Se puder postar a solução eu agradeço!!

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.


×
×
  • Create New...

Important Information

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