How to run count with two tables

Scripts Diversos para o Oracle SQL*Plus. (Relacionado a ferramenta Oracle SQL*Plus, para questões de SQL, usar o forum SQL)
Post Reply
mbaer
Rank: Estagiário Júnior
Rank: Estagiário Júnior
Posts: 2
Joined: Mon, 01 Jun 2009 3:58 pm
Location: blumenau-sc

This is my first post.
I have two tables as below .....

Select all

select B.DTEMISSAO,  
A.NUMNF,  
A.DESCPROD1,  
A.DESCPROD2,  
A.NRORDFABR,  
A.NRPROPOSTA,  
B.CGCFAT, 
A.qtmil 
FROM FATUR.B B, FATUR.A A 
WHERE B.NUMNF = A.NUMNF AND  
((B.dtemissao >= &"EmissaoNF_Inicial")) and 
((B.dtemissao <= &"EmissaoNF_Final")) AND 
((A.DESCPROD2 Like '%1.150-9%') OR  
(A.DESCPROD2 Like '%82000.8%') OR  
(A.DESCPROD1 Like '%1.150-9%') OR  
(A.DESCPROD1 Like '%82000.8%')) 
order by A.qtmil,B.dtemissao
What precise is that only the total number of repeated records .QTMIL. Obeying all the criteria of WHERE.

Thanks from já ....
RodrigoValentim
Moderador
Moderador
Posts: 367
Joined: Tue, 25 Mar 2008 3:41 pm
Location: Salvador - BA
Rodrigo Valentim
Analista de Sistemas
Oracle Developer

Campanha: Faça uma pesquisa antes de perguntar!!!

Of a count (a.qtmil), group by in the stem of the columns and puts a HAVING count (A.QTMIL)> 1
mbaer
Rank: Estagiário Júnior
Rank: Estagiário Júnior
Posts: 2
Joined: Mon, 01 Jun 2009 3:58 pm
Location: blumenau-sc

ok ..... I performed but did not have the desired effect ......
he just made him appear 1 count for every item alter .... if you can only confirm at what moment I insure the HAVINGCOUNT?

TKS [/ img]
RodrigoValentim
Moderador
Moderador
Posts: 367
Joined: Tue, 25 Mar 2008 3:41 pm
Location: Salvador - BA
Rodrigo Valentim
Analista de Sistemas
Oracle Developer

Campanha: Faça uma pesquisa antes de perguntar!!!

after the group by you put the HAVING count> 1
Post Reply
  • Information
  • Who is online

    Users browsing this forum: No registered users and 16 guests