error query sql

  • Folks

    I have a query with error

    ssql = "SELECT b.pn_bnc, b.model_bnc, Count(b.pn_bnc) AS Bounce, (SELECT COUNT(Bounce.laudo_new) FROM Bounce WHERE (Bounce.laudo_new = 'Sem defeito') AND (Bounce.bnc90d = b.bnc90d)) AS NTF FROM Bounce AS b WHERE(((b.bnc90d) = 'VERDADEIRO')) GROUP BY b.pn_bnc, b.model_bnc, b.bnc90d"

    when I run the query, for "NTF" return the sum but isn't group by pn_bnc

    what can be?

    Tks!

  • Try to add an Order by Clause:

    Select ()

    From()

    Where()

    Group by ()

    Order by ()

    Hope this helps

  • Your not grouping by pnc_bnc alone. You have three different pieces to your group clause.

    GROUP BY b.pn_bnc, b.model_bnc, b.bnc90d

  • Folks,

    I move my query let's see

    SELECT teste.tecnico,teste.nome (select sum(teste.qtd) from teste where teste.setor_dest= 'IRMOT' ) AS HF, (select sum(teste.qtd) from teste where teste.setor_dest= 'QCC') AS TT

    FROM teste

    GROUP BY teste.tecnico, teste.nome;

    I am trying group two "select" of same table, but this query return one value for all registrer 🙁

    What can be?

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply