Hello,
This is the situation.
table a
cola1 cola2
table b
colb1 colb2 colb3 colb4 colb5
table c
colc1 colc2 colc3
for every value of cola2 = colb1 and colb4 = colc12 , fetch colb2
for every value of cola2 = colb1 and colb5 = colc3, fetch colb3
calculate (colb3- colb2) * size * factor1 for every cola2.
Calculate SUM((colb3- colb2) * size * factor1) for every cola2
Calculate AVG((colb3- colb2) * size * factor1) for every cola2
the value of (colb3- colb2) * size * factor1 needs to stored in a table for other calculations as well. I tried using multi statement table valued user defined function. But unable to return both aggregate values and single values in the same table. How would I use multiple UDFs in the same join query? Is there any other feature I can use?
Sample data :
table a
id1 prod1
table b
id1 datefrom dateto id1 id2
id2 datefrom dateto id3 id4
table c
id1 date price
id2 date price
id3 date price
id4 date price
table b(id1) matches table c(id1)
table b(id2) matches table c(id2)
i need to fetch the price from table c for both the ids in table b so i can subtract the values and find the sum of the results
Appreciate any help. Thanks.