Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Excluding in a sql query

Author  Topic 

nbs
Starting Member

22 Posts

Posted - 2007-01-02 : 15:04:25
I am trying to accomplish the following.

There are two tables. the second one is a table that contains fields based on which the exclusion logic has to be written. It has 5 fields and there may be data in all of them or only in some of them.

The first and second table have one field in common - the Account number.(ACCT_NUM)
Also the second table is in a different database

the exclusion is based in steps..

1) if it has all the fields in the second table for that account number, then compare all of them..
2) if only 4 of them are present,compare and check for null for the rest
3) if only 3 of them are present,compare and check for null for the rest
4) if only 2 of them are present,compare and check for null for the rest.

how do i do this... pls suggest

thanks

jezemine
Master Smack Fu Yak Hacker

2886 Posts

Posted - 2007-01-02 : 16:16:23
not sure what you are asking for here. do you want to write a select query? if so, post the table DDL and some sample data, and expected results.


www.elsasoft.org
Go to Top of Page

jezemine
Master Smack Fu Yak Hacker

2886 Posts

Posted - 2007-01-02 : 17:06:26
duplicate post

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=76998


www.elsasoft.org
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-01-02 : 17:50:49
Do you have some sample data?
When comparing the two columns, does it matter which columns in table1 to be searched?
If two columns are present, does it matter which order the hits are matched? Do both columns has to be present? Or ony one of them? What it the two columns has same value (for example 25), does value 25 need to be present only one time or two times in table1 and same record?


Peter Larsson
Helsingborg, Sweden
Go to Top of Page
   

- Advertisement -