alternative of UDF

  • i need to do gradntotal , i created UDF(scalar),but i cannot include in select statement coz of where clause it not getting correct total,what is alternative of this

  • Why can't you add the grand total once in SSRS or whatever tool you are using to show the data?

  • Huh?

    Please post table definitions, sample data and desired output. Read this to see the best way to post this to get quick responses.

    http://www.sqlservercentral.com/articles/Best+Practices/61537/

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • i need to do in sp only

  • daveriya (9/20/2011)


    i need to do in sp only

    Why?

  • coz its joining multiple views and then it comes as a grandtotal

  • daveriya (9/20/2011)


    coz its joining multiple views and then it comes as a grandtotal

    Why do you have to do the grand total in the SP instead of the front end where I recommend to do it?

  • i have to use that grand total in formula and then i need to show result

  • Read up on Grouping Sets (or post the information I asked for)

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • there are so many sum function in my select statement,if i do grouping sets ,it will apply to all funcion,i just want for particular function

  • We can't see what you see. Provide the info Gail asked for if you really want our help. Else wise all you are going to get are wild shots in the dark that won't help or snarky answers.

  • just wondering if this post has any relevance to this one by same OP...???

    http://www.sqlservercentral.com/Forums/FindPost1176651.aspx

    ________________________________________________________________
    you can lead a user to data....but you cannot make them think
    and remember....every day is a school day

  • I AM GETTING ERROR LIKE Windowed functions cannot be used in the context of another windowed function or aggregate.

    WHEN I AM USING THIS

    SUM((PMT/ (sum(SUM(ISNULL(PMT,0)))over() ) * VALUE))OVER() as AMOUNT

    SO I M USING UDF FOR (sum(SUM(ISNULL(PMT,0)))over() ) VALUE,BUT ITS TAKING LONGER TIME ,I WANT TO REDUCE TIME ,SO I WANT ALTERNATIVE OF UDF

  • Please post table definitions, sample data and desired output. Read this to see the best way to post this to get quick responses.

    http://www.sqlservercentral.com/articles/Best+Practices/61537/

    And please don't shout at us (post in all caps). We do want to help.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • this function is the only my problem,nothing else

Viewing 15 posts - 1 through 15 (of 20 total)

You must be logged in to reply to this topic. Login to reply