Calculating %'s

1. Join Date
Dec 1969
Posts
30

## Calculating %'s

Hi,<BR><BR>I need to perform a calculation that subtracts 25% from each price record retrieved from an SQL query that is over 40.<BR><BR>Any Ideas<BR>regards<BR>Duncan<BR><BR>

2. Senior Member
Join Date
Dec 1969
Posts
16,931

## RE: Calculating %'s

I&#039;m not sure what you want.<BR><BR>You want to do this in SQL, or using ASP?<BR><BR>If you want to do it automatically using SQL then you&#039;re going to have to use a CASE statement inside your query to accomplish this. I don&#039;t know if Access supports this. Something like "SELECT CASE ProductPrice WHEN &#062;40 THEN (ProductPrice*.75) ELSE ProductPrice END As PercPrice".<BR><BR>If you want to do it in ASP...<BR><BR>if objRS.Fields("ProductPrice") &#062; 40 then<BR> PercPrice = CDbl(objRS.Fields("ProductPrice")) * .75<BR>else<BR> PercPrice = CDbl(objRS.Fields("ProductPrice"))<BR>end if<BR><BR>Craig.

3. Join Date
Dec 1969
Posts
86

## RE: Calculating %'s

My Grandma was an Access guru not so long ago. She ingrained in me the use of the IIF statement which makes the SQL CASE statement look as long-winded as her brother-in-law&#039;s wedding speeches (he has 4 daughters so he&#039;s had practice).<BR><BR>Try:<BR><BR>IIF(ProductPrice&#06 2;40,ProductPrice*0.75,ProductPrice) AS ProducePrice<BR><BR>lokidude@hotmail.com<BR>You&#0 39;re either a statistic or history. Or both.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•