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 |
|
snufse
Constraint Violating Yak Guru
469 Posts |
Posted - 2009-04-09 : 08:03:47
|
| I have a query where I need to compare 1 field against value of 2 fields.Table 1: Field 1: Value: 01004-AVTable 2: Field1: Value: 01004 Field 2: Value AVSometimes there are no value in Field 2, then need to compare only the Field1'sThank you |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2009-04-09 : 08:07:25
|
| SELECT * FROM Table1 T1INNER JOIN Table2 T2ON T1.Field1=CASE WHEN T2.Field2 IS NULL THEN T2.Field1 ELSE T2.Field1 + '-' + T2.Field2 END |
 |
|
|
|
|
|