create sql str with special condition
hellow
I have 2 table
Table a(code, price, check)
Table b(code, percent)
I want to create a sql string such below:
Select a.code, a.price, (price * percent) as new_field
From a,b
Where a.code = b.code
And this condition must be consider in sql str:
If (check = 1)
{
New_field = price * percent
}
Else
{
New_field = price * percent * 8
}
Now how can put above condition in sql str?
Thanks very much