Fórum Duvidas com SQL #235857
02/06/2004
0
Estou precisando fazer uma query para saber quais os cliente que não compra em uma certa data.
Tenho a Tabela1 com os campos Dt_Venda, Cod_Clie e Tabela2 com dos dados dos clientes Cod_Clie.
se Alguém poder me ajudar
Walbert
Wcprog
Curtir tópico
+ 0Posts
02/06/2004
Ale.riopreto
Tenho a Tabela1 com os campos Dt_Venda, Cod_Clie e Tabela2 com dos dados dos clientes Cod_Clie.
Select * from Tabela1
where Dt_Venda - Getdate() >= :dias
:dias -> parametro que vc ira passar na query antes de dar o open..
ex.
Query1.Close;
Query1.ParambyName(´dias´).asfloat:=60;
Query1.Prepare;
Query1.open;
Gostei + 0
03/06/2004
Adilsond
select c.cod_clie, c.nom_clie, c.... from tabclie c where not exists (select 1 from tabvend v where v.cod_clie = c.cod_clie and v.dt_venda not between :dtini and :dtfin) order by c.nom_clie
ou
select c.cod_clie, c.nom_clie, c.... from tabclie c where c.cod_clie not in (select distinct v.cod_clie from tabvend v where v.dt_venda between :dtini and :dtfin) order by c.nom_clie
Gostei + 0
03/06/2004
Aroldo Zanela
Eu faria da seguinte forma:
SELECT * FROM TABELA1 INNER JOIN TABELA2 ON (TABELA1.cod_clie = TABELA2.cod_cli) WHERE DATA_COMPRA <= :X_DATA
Gostei + 0
Clique aqui para fazer login e interagir na Comunidade :)