• niladri.primalink (5/3/2013)


    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?

    Can you post the whole query please?

    “Write the query the simplest way. If through testing it becomes clear that the performance is inadequate, consider alternative query forms.” - Gail Shaw

    For fast, accurate and documented assistance in answering your questions, please read this article.
    Understanding and using APPLY, (I) and (II) Paul White
    Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden