Skip to content
Advertisement

SQL – using IF statement after WITH statement

i am making a SQl report, which uses the With statment, and with a lot of inner joins and group etc.

see Working Code below. the code below does work.

the problem is, this table will have output data (as a table) sometime and sometime not based on order intake. when there is not data found, i want to display a specific message of myself, say “dont need to buy pallet”

i want to put a IF statement after the original queue, such as:

however, if i include the code above, the queue not run, can someone tell me how to put the IF statement after the With as and Select.

(not an SQL expert, sorry if my question not making perfect sense)

————-Working code———–

— end of NewTable

Advertisement

Answer

SQL is not a language that performs logical operations like that, because it is declarative and not procedural.

However, some database systems will offer procedural support, and might have a syntax like:

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement