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 |
|
jigneshsoni
Starting Member
1 Post |
Posted - 2005-09-02 : 00:42:55
|
| hello guys, i am new to sql server,i have one query in procedure, i want to select fields in a select query, but among them one field comes dynamically depends on the value of the record.my structure is like thisi have two tables clients and misc, misc table contains few client names in one column and another column contains one field name of client table likeclient1 date1client2 date1client3 date2etc...now while displaying clients in a select query, if client is client1 then i want to display second field value from date1, if client is client2 then again i want to display second field value as date1 but client is client3 then i want second field's value as date2 in select query.client table;s structure is like this..client date1 date2 date3client1 date11 date12 date13client2 date21 date22 date23client3 date31 date32 date33and i want outout like this in select queryclient misc_dateclient1 date11client2 date21client3 date32please help me to solve this procedure |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-09-02 : 01:17:13
|
| Not sure whether this is what you wantedSelect Client, Case when Client='Client1' then Date1 else Date2 end as misc_datefrom yourTableOtherwise post some sample data and the result you wantMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|