If I have:
table tblA with a field:
------------------------------------------------
[Account Number] defined as nvarchar 10
table B with 2 fields:
-----------------------------------------
Branch defined as nvarchar 3
Email defined as ntext 16
sample of records
--------------------
tbl A
[Account Number]
---------------------
001 123456
001 234567
001 245466
003 345633
003 465454
tbl B
Branch Email
--------- ---------
001 joe.smith@verizon.com
002 jane.doe@verizon.com
003 jeff.smith@verizon.com
How would you write a select to retrieve the tbl B Branch and Email values only if they exist on tbl A ?
Left([Account Number],3)= tblB.Branch
001 joe.smith@verizon.com
003 jeff.smith@verizon.com
Since there is no branch 002 among the [Account Number] values, it is bypassed.
Also, I only want to write out 1 record per branch even though there are mulitple occurrences of a "branch" (the first 3 positions of the [Account Number] in tbl A.
table tblA with a field:
------------------------------------------------
[Account Number] defined as nvarchar 10
table B with 2 fields:
-----------------------------------------
Branch defined as nvarchar 3
Email defined as ntext 16
sample of records
--------------------
tbl A
[Account Number]
---------------------
001 123456
001 234567
001 245466
003 345633
003 465454
tbl B
Branch Email
--------- ---------
001 joe.smith@verizon.com
002 jane.doe@verizon.com
003 jeff.smith@verizon.com
How would you write a select to retrieve the tbl B Branch and Email values only if they exist on tbl A ?
Left([Account Number],3)= tblB.Branch
001 joe.smith@verizon.com
003 jeff.smith@verizon.com
Since there is no branch 002 among the [Account Number] values, it is bypassed.
Also, I only want to write out 1 record per branch even though there are mulitple occurrences of a "branch" (the first 3 positions of the [Account Number] in tbl A.