## SQL calculation

## SQL calculation

(OP)

Hello, I have an SQL statements that uses 3 fiels

This works well but if I want to multiply the pcsper times the quantity it sometimes does the calculations and it sometimes does not. here is the code I am using

the above gives me the following

Not sure why the sql statement won't work with all the rows. kind of stomp on tis one.

any help is much appreciated

#### CODE

(case when TBC='P' then 1/SRLHU end)as pcsper

#### CODE

((case when TBC='P' then 1/SRLHU end)*TQCTD)as STDHrs

the above gives me the following

#### CODE

TBC pcsper SRLHU TQCTD STDHrs P .00200 500.00 2610 P .00238 419.99 98 .2333 P .00294 339.99 1936

any help is much appreciated

## RE: SQL calculation

How did pcsper get onto the line with the other values? The posted code would not do this . . . .

## RE: SQL calculation

I think, like papadba suggests, we'd have to see the full code. I wondered whether you were exceeding the results column's capacity by the arithmetic but as the TQCTD column has no decimal place differences between the values, I'm not sure that's the answer. Also, based on your data, I knocked up the following SQL which mimics what you are doing, and this produces 3 values quite happily.

## CODE

Let us have a look at the actual code that is producing these reuslts.

Marc

## RE: SQL calculation

here is the code I am using

## CODE

## RE: SQL calculation

## RE: SQL calculation

## CODE

but that gives me the same result as

## CODE

## RE: SQL calculation

Ties Blom

## RE: SQL calculation

## CODE

HTH,

Larry

## RE: SQL calculation

I did try that and get the same results as in the original Case statement.

I thought that the TBCDE field might be an alpha field but when I multiply, divide, subtract or add to the field it works fine, if I do the case statements by themselves it also works but then when I try to add them it does not. see this example

## CODE

but if I try to do this

## CODE

## RE: SQL calculation

Ties Blom