IF() function in query syntax

H

hSiplu

hi,
I am looking for a function.
it's like IF() in MySQL.
suppose a table,

[sample_table]
memo, name, sex, amount
1, cust1, 'M',100
2, cust2, 'F', 200
3, cust2, 'F', 230
5, cust4, 'F', 460
6, cust1, 'M',70

In MySQL I would query "SELECT name, IF(sex='M','GUY','LADY') as type,
amount from sample_table where memo < 5";

and the result set,
name type amount
cust1 GUY 100
cust2 LADY 200
cust2 LADY 230
---------------------------------------------------------------------

now, I want this result set from that table.
what would be the equavalent query or IF() function in this case?

please help !
I am stuck,
 
M

Marshall Barton

hSiplu said:
hi,
I am looking for a function.
it's like IF() in MySQL.
suppose a table,

[sample_table]
memo, name, sex, amount
1, cust1, 'M',100
2, cust2, 'F', 200
3, cust2, 'F', 230
5, cust4, 'F', 460
6, cust1, 'M',70

In MySQL I would query "SELECT name, IF(sex='M','GUY','LADY') as type,
amount from sample_table where memo < 5";

and the result set,
name type amount
cust1 GUY 100
cust2 LADY 200
cust2 LADY 230


IIF(sex='M','GUY','LADY') as type
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top