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.
| Author |
Topic |
|
gmmw
Starting Member
3 Posts |
Posted - 2009-10-18 : 16:23:03
|
| I'm trying to perform a case when from two different instances. I know how to write a case when, but I can't seem to think of how to do this one. me. is first instance of table, while pe. is second instanceexample - case when ***** then me.addr1 else pe.addr1 end as ****how do I get all the fields for the first instance if meets that criteria, I need addr1, addr2, city, state and zip for the me. instance or else I need addr1, addr2, city, state and zip for the pe. instance.GMMW |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2009-10-18 : 16:31:01
|
You have to do a similar case for each wanted output-column. No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
jimf
Master Smack Fu Yak Hacker
2875 Posts |
Posted - 2009-10-18 : 16:34:42
|
| No where near enough info to answer this question. What are the criteria, why do you have two instances of the same table? Why would you expect different results from each table. What are your criteria? etc., etc. What does this mean end as ****? Please give us enought info ti solve your problem.JimEveryday I learn something that somebody else already knew |
 |
|
|
gmmw
Starting Member
3 Posts |
Posted - 2009-10-18 : 16:41:45
|
I have two instances, because all of the addresses are in the same table (member, serv provider, payto provider, rendering provider, etc).quote: Originally posted by jimf No where near enough info to answer this question. What are the criteria, why do you have two instances of the same table? Why would you expect different results from each table. What are your criteria? etc., etc. What does this mean end as ****? Please give us enought info ti solve your problem.JimEveryday I learn something that somebody else already knew
GMMW |
 |
|
|
gmmw
Starting Member
3 Posts |
Posted - 2009-10-18 : 16:43:34
|
| case when p.fedid = ('111111111') then me.addr1 else pe.addr1end as payee_addressi want to get all the me. info - city, state, zip or all the pe. info - city, state, zipGMMW |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2009-10-18 : 16:45:18
|
But it is fact that one case construct can only return one result so an own case statement for each conditional output-column is needed. No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
|
|
|
|
|