lsy
September 21st, 2005, 11:32 PM
if i got 2 table
Table1
-------
WorkWeek Value
28 212
28 242
28 435
28 534
29 254
29 542
30 984
Table2
------
WorkWeek ValueX
28 453
28 22
29 124
29 232
29 12
30 54
30 546
30 324
i want my result as
WorkWeek
Sum(Table1.Value) AS SumVal
COUNT(Table2.ValueX) AS CountValX
Sum(Table1.Value) / COUNT(Table2.ValueX) AS Answer
WorkWeek SumVal CountValX Answer
---------------------------------------------
28 1423 2 7115
29 706 3 265.33
30 984 3 328
so how can my sql statement should look like... join 2 table which get the sum of Value in Table1 and count the row of table 2 which both group by WorkWeek and take both to devided it...
Is it possible make it in one sql statement?
Table1
-------
WorkWeek Value
28 212
28 242
28 435
28 534
29 254
29 542
30 984
Table2
------
WorkWeek ValueX
28 453
28 22
29 124
29 232
29 12
30 54
30 546
30 324
i want my result as
WorkWeek
Sum(Table1.Value) AS SumVal
COUNT(Table2.ValueX) AS CountValX
Sum(Table1.Value) / COUNT(Table2.ValueX) AS Answer
WorkWeek SumVal CountValX Answer
---------------------------------------------
28 1423 2 7115
29 706 3 265.33
30 984 3 328
so how can my sql statement should look like... join 2 table which get the sum of Value in Table1 and count the row of table 2 which both group by WorkWeek and take both to devided it...
Is it possible make it in one sql statement?