Query for finding the sum of a field by relating two tables based on a condition

Hi ,

Can anyonehelp me on this?

I have two tables Table1 and Table2.

In Table1 there are 4 fields: ItemId, value(real type), Done (NoYes type) and SetupId(string type).

In Table2 there are 2 fields: SetupId, Include (NoYes type) (SetupId is primary key in this table)

Now I have ItemId which I am passing to a method.

In this method I have to calculate the sum of value for this ItemId from Table1 when

  1. Done field of Table1 is set to 'YES.

If Done field is ‘NO’ then calculate sum of Value when

  1. SetupId of Table1 is equal to setupId of Table2 and Include field of Table2 is set to ‘YES’

I have to get it with the query not using the select statement.

Can anyone please provide me the query for this?

Any help on this please ?

Any help on this please ?