I have a standard insert in / select that is formatted similarly to this:
insert into Table
( ...,
...)
select
field1,
field2,
field3,
field4,
fieldetc
from .... etc
In the select statement there are three specific fields that will need different values, selected depending on another field, let its checker call it, and three fields - field2, field3 and field 4. The values ββwill be either 0, or in another situation, you need a case when. My question is: how do I format the if / else statement so that it works in the select statement? As I have now, it looks like this:
select
field1data,
if checker = 'A' or checker is null
begin
0,
0,
0,
end
else
begin
case when ... then ... else ... end,
case when ... then ... else ... end,
case when ... then ... else ... end,
end
fieldetcdata
from... etc
This returns errors. How can I format this so that it works correctly, either by choosing zeros for these three fields, or by performing my case when the statements are in a different situation. Thank!
source
share