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 |
|
pecusio
Starting Member
5 Posts |
Posted - 2010-02-01 : 05:34:56
|
| I have two table one have a range that identify a sector, something likeSector Initial FinalFinance 1 1200Health 1340 2144In another table I have a code that identify each company to a sector, I would like to have a condition on my query that when the code of the company is between the initial and final it brings me the sector but when the code does not match any sector from the first table it bring me "other" |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-02-01 : 05:40:02
|
| [code]SELECT t.*,COALESCE(s.Sector,'Other')FROM YourTable tLEFT JOIN SectorTable sON t.code BETWEEN s.Initial AND s.Final[/code] |
 |
|
|
pecusio
Starting Member
5 Posts |
Posted - 2010-02-01 : 06:02:52
|
| Thanks for the fast response |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-02-01 : 06:06:20
|
| welcome |
 |
|
|
|
|
|