Case statement
-
Tuesday, November 28, 2006 8:34 AM
Hi
I am having a few problem with a case statement.
I have a table with customer data in and I need to bring back all the rows
which have data missing from 2 different columns.customer table
CustomerID Name SoftwareVersion
1001 TEST1 V5
1002 TEST2 V5
3 TEST3 V5
004 TEST4 V6
ect..
CustomerID Table
ID
1001
1002
1003
1004
ect...
I have a need customerid table and I need to list all the customers who are
not in this table or whos id does not match the new listings,
alos there is a softwareVersion Table list all the newest software so the same
will need to be done for this.Thanks
Rich
All Replies
-
Tuesday, November 28, 2006 9:04 AM
You need to create the join batween the two table with CustomerID & ID, with not equal operator, yuor query may look like this
SELECT
A.CustomerID FROM customer A , customerID BWHERE
A.CustomerID != B.IDGurpreet S. Gill
-
Tuesday, November 28, 2006 9:09 AM
Hi
I would like to use the case statement because where there is an error, I would like the cell to display
ERROR: 'then customerid'
Thanks
Rich
-
Tuesday, November 28, 2006 9:32 AM
I dont get you, what you want to do ? tell me in more detail.
-
Tuesday, November 28, 2006 8:44 PM
SELECT A.CustomerID FROM customer A , customerID B WHERE
A.CustomerID != B.IDThis won't work, you're just going to get every Customer joined to every customer except themselves.
You need to use an outer join something like this
SELECT A.CustomerID
FROM Customer A
LEFT JOIN CustomerID B ON A.CustomerID = B.[ID]
WHERE B.ID IS NULL -
Tuesday, November 28, 2006 8:46 PMI assume you mean that the CustomerID table in your example above is really the result of a query you want to write. The problem is you haven't specified what "all the customers who are not in this table or whos id does not match the new listings" means. How do you know if a customer is not in that table or if they do not match the new listings, is that info in another table?
-
Thursday, November 30, 2006 5:25 AM
yes SnMSDN
he didnt make much clear what he wants, that why i did post that sample code. But he not responding, might he had solved the problem

