Table left on SQL

Este forum é dedicado a códigos errados que se encontram por aí, ou seja, coisas que não se deve fazer de jeito nenhum! Não coloque neste forum dúvidas! (apenas situações bizarras do nosso dia a dia :-)
Post Reply
User avatar
dr_gori
Moderador
Moderador
Posts: 5024
Joined: Mon, 03 May 2004 3:08 pm
Location: Portland, OR USA
Contact:
Thomas F. G

Você já respondeu a dúvida de alguém hoje?
https://glufke.net/oracle/search.php?search_id=unanswered

Below a pearl in production:

Select all

select a.rowid, 
          a.nome as Area,  
          a.area_id as CodArea,  
          f.nopessoa as Nome,  
          f.cdpessoafunc as CodNome, 
          decode(a.ativo,'S','Sim','N','Não') as Ativo 
   from funcionarios f, area a, 
        solicitantes s 
   where a.responsavel = f.cdpessoafunc 
   group by a.rowid, a.nome, a.area_id, f.nopessoa, f.cdpessoafunc, a.ativo 
   order by 2;
Errors:
* The "requesters" table is not used at all! Just create a Cartesian product!
* To solve the problem, a group BY was placed, to eliminate the Cartiando product

Posted by Rodrigo Nascimento - Partnership

: - D
DanielNN
Moderador
Moderador
Posts: 641
Joined: Mon, 03 Sep 2007 3:26 pm
Location: Fortaleza - CE
att,

Daniel N.N.

Post is old but problem is routine.

Time or another, in addition to these "Group By" to remove consultation failures (or bank modeling), I see things like:

Select all

SELECT DISTINCT 
... 
FROM 
... 
GROUP BY ....;
I think they think that group by with distinct gives double reinforcement for the inconsistencies and integrity of the bank.
: MRGreen:
User avatar
dr_gori
Moderador
Moderador
Posts: 5024
Joined: Mon, 03 May 2004 3:08 pm
Location: Portland, OR USA
Contact:
Thomas F. G

Você já respondeu a dúvida de alguém hoje?
https://glufke.net/oracle/search.php?search_id=unanswered

Heoheoe
Yes, to ensure, put the distinct. :-D
DanielNN
Moderador
Moderador
Posts: 641
Joined: Mon, 03 Sep 2007 3:26 pm
Location: Fortaleza - CE
att,

Daniel N.N.

And we do not forget the "Rownum = 1" as the cake cherry. : lol :: lol :: lol:
Post Reply
  • Information
  • Who is online

    Users browsing this forum: No registered users and 12 guests