Interview Question asked before.
Given a table with columns boxName and value,find the volume of each box. Value field has the lenght,bredth and height of a cube. I am required to multiply all the tree dimensions.
I can use a groupby if the sum need to be calculated, but here product is required
box1 = 12*13*1 = 156
box2 = 1*23*6 = 138
box3 = 12*1*20 = 240
+---------+-------+
| boxName | value |
+---------+-------+
| box1 | 12 |
| box1 | 13 |
| box1 | 3 |
| box2 | 1 |
| box2 | 23 |
| box2 | 6 |
| box3 | 12 |
| box3 | 1 |
| box4 | 30 |
+---------+-------+