-
SQL Query retrieving data where one key field may be null
Okay, so there's a table that is essentially arranged with a two-column key, but one of the columns might be null. And if it's null and is joined against another table (in the example below, say I'm looking for a query that pulls all the customers and plans, if the plan is null I want to pull the customer cost. If there's a customer row with the plan, though, I want to pull the cost from that row.
CUSTOMER |
PLAN |
COST |
VENDCO |
LMN |
50 |
VENDCO |
|
25 |
BUYCO |
|
10 |
I'm trying to run a query that will pull this into one field, i.e., the value of VENDCO at 50, and the value of BUYCO at 10, ignoring the VENDCO row with 25. This would be as part of a joined subquery, so I can't use the actual keys of VENDCO/BUYCO etc. Essentially, pick the cost value with the plan if it exists, but the one where it's null if the plan is not there.
Hope I'm making myself clear.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|