Dúvidas Group by (ireport)

Asked

Viewed 18 times

0

I am using the same query:

Select
TAB.DESCRPROD,
PRO.DT_INC,
PRO.QTD_FALT,
PRO.OBS,
PRO.CODPROD,
RETIRA,
PRAZO,
PREV_ENTREGA,
NRO_OF,
NRO_OP,
MODELO,
SEPARACAO,
MONTAGEM,
GAB,
PROD_CLIENTE,
STATUS,
ORIGEM,
SETOR,
(CASE WHEN ORIGEM = 'F' THEN 'FINALIZADO'
when ORIGEM = 'P' THEN 'PRODUÇÃO'
WHEN ORIGEM = 'A'THEN 'ALMOXARIFADO'
ELSE ORIGEM END) AS ORIGEM2
,
(CASE WHEN GAB = '1' THEN 'N/A'
when GAB = '2' THEN 'FAL.'
WHEN GAB = '3' THEN 'OK'
ELSE GAB END) AS GAB2
,
(CASE WHEN PROD_CLIENTE = '1' THEN 'N/A'
when PROD_CLIENTE = '2' THEN 'FAL.'
WHEN PROD_CLIENTE = '3' THEN 'OK'
ELSE PROD_CLIENTE END) AS EMB
from
AD_FALTAPECAS PEC

INNER JOIN AD_PRODUTOS PRO ON
PEC.SEQUENCIAL=PRO.SEQUENCIAL
INNER JOIN TGFPRO TAB ON
TAB.CODPROD=PRO.CODPROD

where

SETOR = $P{P_SETOR} and
ORIGEM != 'F' AND
PRO.STATUS_ENT = 'P'

order by PRAZO

I’d like to add a Group by PRO.CODPROD. But when I do I get the error message:

Invalid 'TGFPRO.DESCRPROD' column in the selection list because it is not is contained in an aggregation function or in the GROUP BY clause.

Please help me out.

  • 1

    It seems to be only about SQL and Voce put Javascript and Java tags, what this has to be?

  • So that the "group by" ?

  • So in my report I’m ordering by Productive Lot and within that lot I have several equipment to produce. Many times a piece or other has some missing piece. The by order is to group the amount of repeated parts in a single batch.

  • Sorry, I did not take any course and do not know language name, I just was learning by trial and error. I did not know it was only SQL.

1 answer

0

You must repeat ALL fields displayed in the SELECT list. In general the clause GROUP BY is used as follows::

SELECT 
  <Lista de campo a apresentar 0 ou mais>,
  <Lista de funções agregadoras sobre um qualquer campo>
FROM <Tabela ou junções de tabelas>
[ WHERE <FILTRO SOBRE DADOS>]
GROUP BY 
  <Lista de campo a apresentar 0 ou mais>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.