Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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???
(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;
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;
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
];
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?
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???
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.
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;
(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;
Thank you so much