dbTalk Databases Forums  

Please Help me!!!

comp.databases.ms-sqlserver comp.databases.ms-sqlserver


Discuss Please Help me!!! in the comp.databases.ms-sqlserver forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
David Méndez
 
Posts: n/a

Default Please Help me!!! - 04-03-2007 , 12:06 AM






I got the following definition tables:

CREATE TABLE VENTAS (
CLIREAL INT NOT NULL,
MATREAL CHAR(10) NOT NULL,
QTY SMALLINT NOT NULL DEFAULT 0,
AMOUNT DECIMAL(9,2) NOT NULL DEFAULT '0.00',
MES SMALLINT NOT NULL,
CLIENTE INT NOT NULL DEFAULT 0,
MATERIAL INT NOT NULL DEFAULT 0
)

CREATE TABLE CLIENTCONV (
CODE INT PRIMARY KEY,
CONV INT NOT NULL DEFAULT 0
)

CREATE TABLE CLIENTES (
CODE INT PRIMARY KEY,
NAME VARCHAR(40) NOT NULL,
VENDEDOR TINYINT NOT NULL DEFAULT 0,
USUARIO INT DEFAULT 0xFFFFFFFF
)

I need to find the members that exists on the following select queries (not
union):

SELECT DISTINCT CLIREAL FROM VENTAS WHERE CLIREAL NOT IN (SELECT CODE FROM
CLIENTES)
SELECT DISTINCT CLIREAL FROM VENTAS WHERE CLIREAL NOT IN (SELECT CODE FROM
CLIENTCONV)

Basically I need to choose the rows VENTAS.CLIREAL that do not exists in
CLIENTES.CODE rows and that also do not exists in the CLIENTCONV.CODE rows.

thank's.

David Méndez.



Reply With Quote
  #2  
Old   
Ed Murphy
 
Posts: n/a

Default Re: Please Help me!!! - 04-03-2007 , 12:26 AM






David Méndez wrote:

Quote:
I need to find the members that exists on the following select queries (not
union):

SELECT DISTINCT CLIREAL FROM VENTAS WHERE CLIREAL NOT IN (SELECT CODE FROM
CLIENTES)
SELECT DISTINCT CLIREAL FROM VENTAS WHERE CLIREAL NOT IN (SELECT CODE FROM
CLIENTCONV)

Basically I need to choose the rows VENTAS.CLIREAL that do not exists in
CLIENTES.CODE rows and that also do not exists in the CLIENTCONV.CODE rows.
select distinct clireal
from ventas
where clireal not in (select code from clientes)
and clireal not in (select code from clientconv)

Alternatively:

select distinct clireal
from ventas
where clireal not in (select code from clientes
union select code from clientconv)


Reply With Quote
  #3  
Old   
David Méndez
 
Posts: n/a

Default Re: Please Help me!!! - 04-03-2007 , 07:39 AM



Great!!!
thank you.

David.

"Ed Murphy" <emurphy42 (AT) socal (DOT) rr.com> wrote

Quote:
David Méndez wrote:

I need to find the members that exists on the following select queries
(not union):

SELECT DISTINCT CLIREAL FROM VENTAS WHERE CLIREAL NOT IN (SELECT CODE
FROM CLIENTES)
SELECT DISTINCT CLIREAL FROM VENTAS WHERE CLIREAL NOT IN (SELECT CODE
FROM CLIENTCONV)

Basically I need to choose the rows VENTAS.CLIREAL that do not exists in
CLIENTES.CODE rows and that also do not exists in the CLIENTCONV.CODE
rows.

select distinct clireal
from ventas
where clireal not in (select code from clientes)
and clireal not in (select code from clientconv)

Alternatively:

select distinct clireal
from ventas
where clireal not in (select code from clientes
union select code from clientconv)



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.