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 |
helixpoint
Constraint Violating Yak Guru
291 Posts |
Posted - 2010-09-09 : 09:09:56
|
I have 2 tables. They are a one to many. In table one. I have clients in table 2 I have multiple AKA's. I have to join the tables to filter out certain AKA's, but I only want to bring back just one client. The SQL below brings back the clint multiple times with different AKA'sSELECT C.CLNT_ID, C.ORGANIZATION_NAME, C.CLNT_TYPE, C.LAST_NAME, C.FIRST_NAME, C.MIDDLE_NAME, C.NAME_SUFFIX, C.EIN, C.DUN, TO_CHAR(C.DATE_STATUS_BEGIN, 'YYYY-MM-DD HH24:MI:SS') AS DATE_STATUS_BEGIN, C.CLNT_COMMENT, AKA.DER_CODE, AKA.AKA, AKA.CLNTAKATP_IDFROM CLIENTS C LEFT OUTER JOINCLIENT_AKAS AKA ON C.CLNT_ID = AKA.CLNT_IDWHERE (AKA.AKA LIKE 'OG%') AND (AKA.CLNTAKATP_ID = 1 ORAKA.CLNTAKATP_ID = 21 ORAKA.CLNTAKATP_ID = 26 ORAKA.CLNTAKATP_ID = 28 ORAKA.CLNTAKATP_ID = 29 ORAKA.CLNTAKATP_ID = 30 ORAKA.CLNTAKATP_ID = 31 ORAKA.CLNTAKATP_ID = 52) AND (AKA.DER_CODE = 9) AND (C.CLNT_ID = 52593) DaveHelixpoint Web Developmenthttp://www.helixpoint.com |
|
CSears
Starting Member
39 Posts |
Posted - 2010-09-09 : 10:14:36
|
So what are you looking for? To just select the first AKA from the list? Can you post some sample result sets (expected versus actual results) |
 |
|
helixpoint
Constraint Violating Yak Guru
291 Posts |
Posted - 2010-09-09 : 10:47:18
|
Ahhh. That got in the by mistake. I don't need anything from the AKA tableDaveHelixpoint Web Developmenthttp://www.helixpoint.com |
 |
|
|
|
|
|
|