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 |
|
paramu
Posting Yak Master
151 Posts |
Posted - 2009-07-18 : 02:09:10
|
| Hi,I want to select a field according to its value...Suppose I have a field "Sample_req", if its value is "Y" then I want to select as a field "sample_req_yes", and if the value id "N" then it has to be a field "sample_req_no".Is is possible?select mpr_no,mpr_date,sample_req="y" as sample_req_yes,sample_req="n" as sample_req_no from mprmst.........???ThanksParamu @ PARANTHAMAN |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-07-18 : 02:12:01
|
| [code]select mpr_no,mpr_date,case when sample_req="y" then 'sample_req_yes' else 'sample_req_no' end as sample_req from mprmst..[/code] |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2009-07-18 : 02:13:26
|
You want as 2 separate field ? one for sample_req = 'Y' and one for 'N' ? KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
paramu
Posting Yak Master
151 Posts |
Posted - 2009-07-18 : 03:26:28
|
| yes. I need 2 - seperate fields...one for sample_req = 'Y' and one for 'N'ThanksParamu @ PARANTHAMAN |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2009-07-18 : 03:28:11
|
[code]select mpr_no, mpr_date, case when sample_req = 'Y' then 'Y' end as 'sample_req_yes', case when sample_req = 'N' then 'N' end as 'sample_req_no'from mprmst[/code] KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
paramu
Posting Yak Master
151 Posts |
Posted - 2009-07-18 : 04:49:00
|
| Thanks For Both Nice Ideas.."Good Services, Keep It Up"Paramu @ PARANTHAMAN |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2009-07-18 : 05:08:13
|
You are welcome. Please come again KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
|
|
|
|
|