• Thank u all for your awesome output.

    It works fine for me. But the same query when I am pasting in SP it shows me the error

    SELECT file_id as bacs_id,

    CASE WHEN EXISTS(SELECT 1 FROM filetransaction WHERE fileid = fb.file_id)

    THEN

    (SELECT sum(CONVERT(float, ft.amount))

    FROM filetransaction ft

    WHERE ft.fileid <>332 and ISNUMERIC(ft.amount)=1)

    it shows me the error

    Msg 8114, Level 16, State 5, Procedure bacs_list, Line 17

    Error converting data type varchar to float.

    but when I am removing CASE WHEN EXISTS(SELECT 1 FROM filetransaction WHERE fileid = fb.file_id) this portion it is giving me the output. I can not remove exists function

    Could u please guide me?