Skip to Content
0
Former Member
May 18, 2004 at 03:24 PM

SQL: Using IF in a SQL-Query

50 Views

Hi there,

I need an automated query for chosing the correct commission for creating an invoice.

If the commission is set within the item sold (Commsion > 0) (OITM.CommisPcnt) SBO should use that one - otherwise it should work with the one of the OSLP-table (OSLP.Commission).

My query looks like that but always sets the commission to 0.00% (There is no error message):

if (select oitm.CommisPcnt from oitm where $[$38.1.0] = oitm.ItemCode) > 0

begin

select oitm.CommisPcnt from oitm inv1 where inv1.SlpCode = oslp.SlpCode

end

else

begin

select oslp.Commission from oslp oinv where oinv. = oitm.ItemCode

END

$[$38.1.0] = ItemCode

Thank you all in advance!!!

Kai