to identify the value 0 before division in a sql

P

pol

How I can decode statement for the following sql

select ( profit_2008 / sales_2008) *100 as margin_2008
from tbl_sales

I need to find out margin_2008 when the value sales_2008 > 0 . Is there
any decode statement in sql using Access.

Please let me a help

With thanks and regards

Polachan
 
S

Stefan Hoffmann

hi Polachan,

pol wrpte:
select ( profit_2008 / sales_2008) *100 as margin_2008
from tbl_sales

I need to find out margin_2008 when the value sales_2008 > 0 . Is there
any decode statement in sql using Access.
Use Iif():

SELECT
Iif(sales_2008 <> 0, profit_2008 / sales_2008, 0) * 100
FROM tbl_sales


mfG
--> stefan <--
 
P

pol

thanks very much

Stefan Hoffmann said:
hi Polachan,

pol wrpte:
Use Iif():

SELECT
Iif(sales_2008 <> 0, profit_2008 / sales_2008, 0) * 100
FROM tbl_sales


mfG
--> stefan <--
 

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

Top