I am trying to run the below script but get the error "Conversion failed when converting the varchar value 'DIFF' to data type int." - Is it possible to convert the temp computed column in the script to an integer for me to run the and <> '0' clause without having to create this into a temp table and run it that way?
SELECT A_ID, (ISNULL(val_a,0) - tesbak.total) AS 'DIFF'
FROM tesMAST F
INNER JOIN (select p_a_id, SUM(ISNULL(val_n,0)) as total from tesmast
where and level_number <> '1'
group by p_a_id) tesBAK
on f.a_id = tesbak.p_a_id
WHERE f.level_number ='1' and 'DIFF' <> 0