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 |
|
collie
Constraint Violating Yak Guru
400 Posts |
Posted - 2008-02-03 : 05:46:31
|
| Hi,I need to write a sql query joining 2 tables. The first table is called IncidentIdStatus and contains 2 columns:statusid and status1 open2 close3 pendingTable MsgInfoExternals contains the followinginstance propvalue26 open34 pending45 close37 closeI need a query that will say that if the propvalue is pending then return only statusid 2,3if it's close then return only 3if open return allhow can i write such a query?thanksWhisky-my beloved dog who died suddenly on the 29/06/06-I miss u so much. |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-02-03 : 07:16:49
|
| [code]SELECT m.instance,m.propvalue,i.statusFROM MsgInfoExternals mCROSS JOIN IncidentIdStatus iWHERE ((m.propvalue='pending' AND i.statusid in (2,3))OR (m.propvalue='close' AND i.statusid =3)OR (m.propvalue='open'))[/code] |
 |
|
|
collie
Constraint Violating Yak Guru
400 Posts |
Posted - 2008-02-03 : 07:39:46
|
Thanks that works wonderful Whisky-my beloved dog who died suddenly on the 29/06/06-I miss u so much. |
 |
|
|
|
|
|