none
Erro na Consulta RRS feed

  • Pergunta

  • Estou com uma dificuldade de rodar a consulta abaixo;

    SELECT 
    T0.[CardCode], 
    T0.[CardName], 
    T0.[DocDate], 
    T0.[DocTotal], 
    T1.[DocTotal],  
    T0.[Serial], 
    T2.[PymntGroup], 
    T3.[SlpName], 
    T4.[NfmName] 

    FROM OINV T0 , ODPI T1 INNER JOIN OCTG T2 
    ON T0.[GroupNum] = T2.[GroupNum] INNER JOIN OSLP T3 
    ON T0.[SlpCode] = T3.[SlpCode] INNER JOIN ONFM T4 
    ON T0.[Model] = T4.[AbsEntry]

    WHERE T0.[DocDate] >= '2017-01-01' AND T0.[DocDate] <= '2017-01-31' AND T0.[CANCELED]= 'N'

    ORDER BY T0.[DocNum]

    Retorna o seguinte erro;

    Mensagem 4104, Nível 16, Estado 1, Linha 13
    The multi-part identifier "T0.GroupNum" could not be bound.
    Mensagem 4104, Nível 16, Estado 1, Linha 14
    The multi-part identifier "T0.SlpCode" could not be bound.
    Mensagem 4104, Nível 16, Estado 1, Linha 15
    The multi-part identifier "T0.Model" could not be bound.

    terça-feira, 21 de fevereiro de 2017 19:08

Respostas

  • Isso é SQL Server? Creio que voce nao possa fazer isso. Tente desta maneira:

    SELECT 
    T0.[CardCode], 
    T0.[CardName], 
    T0.[DocDate], 
    T0.[DocTotal], 
    T1.[DocTotal],  
    T0.[Serial], 
    T2.[PymntGroup], 
    T3.[SlpName], 
    T4.[NfmName] 
    
    FROM OINV T0 
          INNER JOIN ODPI T1 ON T0.???? = T1.????      --- falta a definiçao do join entre T0 e T1
          INNER JOIN OCTG T2 ON T0.[GroupNum] = T2.[GroupNum] 
          INNER JOIN OSLP T3 ON T0.[SlpCode] = T3.[SlpCode] 
          INNER JOIN ONFM T4 ON T0.[Model] = T4.[AbsEntry]
    WHERE (T0.[DocDate] between  '2017-01-01' AND '2017-01-31') AND T0.[CANCELED]= 'N'
    ORDER BY T0.[DocNum]
    att



    William John Adam Trindade
    Analyste-programmeur
    ----------------------------------------------------------

    terça-feira, 21 de fevereiro de 2017 19:15

Todas as Respostas

  • Isso é SQL Server? Creio que voce nao possa fazer isso. Tente desta maneira:

    SELECT 
    T0.[CardCode], 
    T0.[CardName], 
    T0.[DocDate], 
    T0.[DocTotal], 
    T1.[DocTotal],  
    T0.[Serial], 
    T2.[PymntGroup], 
    T3.[SlpName], 
    T4.[NfmName] 
    
    FROM OINV T0 
          INNER JOIN ODPI T1 ON T0.???? = T1.????      --- falta a definiçao do join entre T0 e T1
          INNER JOIN OCTG T2 ON T0.[GroupNum] = T2.[GroupNum] 
          INNER JOIN OSLP T3 ON T0.[SlpCode] = T3.[SlpCode] 
          INNER JOIN ONFM T4 ON T0.[Model] = T4.[AbsEntry]
    WHERE (T0.[DocDate] between  '2017-01-01' AND '2017-01-31') AND T0.[CANCELED]= 'N'
    ORDER BY T0.[DocNum]
    att



    William John Adam Trindade
    Analyste-programmeur
    ----------------------------------------------------------

    terça-feira, 21 de fevereiro de 2017 19:15
  • Boa tarde,

    Bulcão, se o objetivo for um Cross Join entre as tabelas OINV e ODPI, experimente trocar a vírgula que está entre as tabelas pelo termo Cross Join.

    Espero que ajude


    Assinatura: http://www.imoveisemexposicao.com.br

    terça-feira, 21 de fevereiro de 2017 19:23