I have a table
MYTABLE
Field1 field2 field3
abc 2 200
abc 2 100
abc 2 -180
bnm 3 -500
bnm 3 450
bnm 3 30
zxc 2 250
zxc 2 -200
zxc 2 -20
Whatever value is in field 1 (abc) will always have a corrsponding field2 (2)
example:
"abc" will always have "2" in field2
"bnm" will always have "3" in field2
"zxc" will always have "2" in field2
etc.etc.
I'm trying to build a sum query where you group by field1 and field2 and then....add a conditional sum field...
Example:
I need one field that would take the minimum absolute value between the sum of all records where field3>0 and field3<0
So my query should take mytable and display...
myquery
field1 field2 field3
abc 2 180 = min( abs(100+200) , abs(-180) )
bnm 3 480 = min( abs(450+30) , abs(-500) )
zxc 2 220 = min( abs(250) , abs(-200-20) )
What would the SQL be?
Thank you in advance
MYTABLE
Field1 field2 field3
abc 2 200
abc 2 100
abc 2 -180
bnm 3 -500
bnm 3 450
bnm 3 30
zxc 2 250
zxc 2 -200
zxc 2 -20
Whatever value is in field 1 (abc) will always have a corrsponding field2 (2)
example:
"abc" will always have "2" in field2
"bnm" will always have "3" in field2
"zxc" will always have "2" in field2
etc.etc.
I'm trying to build a sum query where you group by field1 and field2 and then....add a conditional sum field...
Example:
I need one field that would take the minimum absolute value between the sum of all records where field3>0 and field3<0
So my query should take mytable and display...
myquery
field1 field2 field3
abc 2 180 = min( abs(100+200) , abs(-180) )
bnm 3 480 = min( abs(450+30) , abs(-500) )
zxc 2 220 = min( abs(250) , abs(-200-20) )
What would the SQL be?
Thank you in advance