|
hi everybody I need to do something like that:
select x.ProductName, sum(x.field1+y.field2) as Mysum, y.field2 from tablexxx as x inner join tableyyy as y on x.id =y.id where as Mysum - y.field2 > 0
obviously it doesnt work!, but I'm looking for suggestions
modified 26-Nov-12 10:42am.
|
|
|
|
|
Something like this should do the trick.
Select ProductName, MySum, field2
From (Select x.ProductName, SUM(x.field1 + y.field2) as MySum, y.field2
From tablexxx as x inner join
tableyyy as y on x.id = y.id) as q
Where MySum - field2 > 0
|
|
|
|
|
Add Group By ProductName, Field2
after the where clause
Never underestimate the power of human stupidity
RAH
|
|
|
|