I have a query that compares values in two columns, row by row, and sums the ABS(diff) to a single scalar int. I want to use the final scalar int to determine if a procedure should be executed.
The query has two WITH and a single SELECT FROM the 2nd WITH like this:
WITH AAA AS (...),
BBB AS (... FROM AAA)
SELECT SUM(I)
FROM BBB
The query works - I get the correct result when it's run as SELECT.
However, when I try to use an IF [result] = 0, I get syntax errors no matter where I put the IF condition.
Is there any way to combine WITH and IF in the way I want?
Aucun commentaire:
Enregistrer un commentaire