Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Help: How to multiply??

I want to calculate cubic space (width * height * length).

so here i have measurements for width, height and length.

what is the expression for cubic space???

1 Solution

Accepted Solutions
Gysbert_Wassenaar

(sum(width) * sum(length) * sum(height))/1728 as CubicSpace

To begin with this is probably not calculating what you want. It first sums all the lenghts, all the widths and all the heights and than multiplies the sums. This is something completely different from sum( widht*length*height).

Next if you use an aggregation function like sum, you need to use the group by clause. Your load script would look like this:

Temp:

SQL SELECT width,

   length,

   height,

   OrderNo

FROM CourierComplete.dbo.CompletedOrderPackages;

CompletedCubicMeasure:

load OrderNo, (sum(width) * sum(length) * sum(height))/1728 as CubicSpace

resident Temp group by OrderNo;

drop Table Temp;


talk is cheap, supply exceeds demand

View solution in original post

8 Replies
Gysbert_Wassenaar

It's width * height * length if your field names are 'width', 'height' and 'length':

load

object, width, height, length,

width * height * length as cubic_space

from ...somewhere;


talk is cheap, supply exceeds demand
swuehl
MVP
MVP

If you do have records that contain your measures, maybe like this

LOAD *,

width*height*length as CubicSpace

INLINE [

room, width, height, length

A, 10, 20, 30

B, 5,8,7

];

Not applicable
Author

CompletedCubicMeasure:

load

*,

width,

length,

height,

OrderNo,

width * Length * Height as CubicSpace;

SQL SELECT

  *

FROM CourierComplete.dbo.CompletedOrderPackages;

this is my code, but it was returned with error. can you please tell me where i made the mistake at?

Not applicable
Author

hi, i dont understand anything after inline

INLINE [

room, width, height, length

A, 10, 20, 30

B, 5,8,7

];

can you please tell me what this is, and what is room and those numbers???

Gysbert_Wassenaar

You will get an error that field names must be unique. The * loads all field names. You then load width, lenght, height and OrderNo again without renaming them.


talk is cheap, supply exceeds demand
Not applicable
Author

Hi Gysbert,

     i am trying to sum up all the width and multiply by all the length, and so on, but my equation shows oledb failed...

my Code:

CompletedCubicMeasure:

load

(sum(width) * sum(length) * sum(height))/1728 as CubicSpace,

*;

SQL SELECT width,

   length,

   height,

   OrderNo

FROM CourierComplete.dbo.CompletedOrderPackages;

Gysbert_Wassenaar

(sum(width) * sum(length) * sum(height))/1728 as CubicSpace

To begin with this is probably not calculating what you want. It first sums all the lenghts, all the widths and all the heights and than multiplies the sums. This is something completely different from sum( widht*length*height).

Next if you use an aggregation function like sum, you need to use the group by clause. Your load script would look like this:

Temp:

SQL SELECT width,

   length,

   height,

   OrderNo

FROM CourierComplete.dbo.CompletedOrderPackages;

CompletedCubicMeasure:

load OrderNo, (sum(width) * sum(length) * sum(height))/1728 as CubicSpace

resident Temp group by OrderNo;

drop Table Temp;


talk is cheap, supply exceeds demand
Not applicable
Author

Thank you so much