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
 Other Forums
 MS Access
 Advanced SQL query

Author  Topic 

asimonse
Starting Member

4 Posts

Posted - 2003-10-02 : 07:43:48
I wan't to make a query as follow:
Source Table:
Column_A
1
2
3
4
5
Query result:
Column_A | Column_B
1 | 0
2 | 1
3 | 1
4 | 1
5 | 0
Add a column in the query result. For all the values form Column_A between 2 and 5 set the value in Column_B to value "1". All the other values should be value "0".
such as (but this query doesn't work in MS Access or VB):
SELECT Column_A,
case when Column_A between 2 and 4 then 1 else 0 end as column_b
FROM Mytable

Stoad
Freaky Yak Linguist

1983 Posts

Posted - 2003-10-02 : 08:31:46
SELECT Column_A,
iif(Column_A >= 2 and Column_A <= 4, 1, 0) as column_b
FROM Mytable
Go to Top of Page

asimonse
Starting Member

4 Posts

Posted - 2003-10-02 : 09:42:31
Perfect, it works!
Go to Top of Page
   

- Advertisement -