Hi,

I think i'm going thru a complicated formula, i'm not sure if there is an easier way to do it.

I currently have the following code , it works fine
a Code:
  1. SELECT user, sum((a,b))
  2. from (select * FROM xxxxkmain where net>0 ) as aaa
  3. group by user

But now wut i wud like to add to my previous query this :
each user belongs to a department (3 depts in total), so depending on the user dept, i wud like to run different formula(if user is in dep 1 then run formula1.....)
Code:
sum((a,b))
<--- this is the formula part

Im sure we will need to use an if statement but i'm not sure how to use it in SQL.
Any tip will e appreciated

thx