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.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 SQL make new field

Author  Topic 

hubschrauber
Starting Member

16 Posts

Posted - 2005-11-10 : 05:01:10
I have the following query in access and i want to transform this query to SQL. It is an iif statement which gives a certain value back and makes an new field in the table.
Now I want to do that also in SQL, but I failed

I hope some can help me....I think I have almost the solution...

Access query:
IIf(r_tbl_el_210_open.ouderdom_2="1","1.Tot een maand na actiedatum",IIf(r_tbl_el_210_open.ouderdom_2="2","2. Tot 2 maanden na actiedatum",IIf(r_tbl_el_210_open.ouderdom_2="3","3. Meer dan 2 maanden na actiedatum"))) AS [ouderdom uitval]

SQL query:
case when r_tbl_el_210_open.ouderdom_2='1' then '1.Tot een maand na actiedatum' else
case when r_tbl_el_210_open.ouderdom_2='2' then '2. Tot 2 maanden na actiedatum' else
case when r_tbl_el_210_open.ouderdom_2='3' then '3. Meer dan 2 maanden na actiedatum' end as [uitval_ouderdom] ,

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-11-10 : 05:37:16
Remove else part

case
when r_tbl_el_210_open.ouderdom_2='1' then '1.Tot een maand na actiedatum'
when r_tbl_el_210_open.ouderdom_2='2' then '2. Tot 2 maanden na actiedatum'
when r_tbl_el_210_open.ouderdom_2='3' then '3. Meer dan 2 maanden na actiedatum' end as [uitval_ouderdom]

Otherwise post some sample data and the result you want

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -