Professional Web Applications Themes

UDF problem - Microsoft SQL / MS SQL Server

Hello ! I made a function that calculates percentile and returns decimal But one slight problem is that it's not dynamic and I want the function to some how look at every row of employee id and return values for every row of employeeID Thank you TKim select distinct employeeid, dbo.oagg(employeeid) from orders...

  1. #1

    Default UDF problem

    Hello !

    I made a function that calculates percentile
    and returns decimal

    But one slight problem is that it's not dynamic and I want the function to
    some how look at
    every row of employee id and return values for every row of employeeID

    Thank you
    TKim

    select distinct employeeid, dbo.oagg(employeeid)
    from orders


    Tkim Guest

  2. #2

    Default Re: UDF problem

    I dont think if there is any problem in your statement ... It would be nice if you can tell us your output also ...

    --
    HTH,
    Vinod Kumar
    MCSE, DBA, MCAD
    SCT Software Solutions
    http://www32.brinkster.com/sqlvinod


    "Tkim" <com> wrote in message news:iFlRa.5524$prod.itd.earthlink.net... 
    Vinodk Guest

  3. #3

    Default Re: UDF problem

    Hi

    I don't have the UDF SQL code with me right now.

    But UDF basically accepts 2 parameters
    which will be used in select statement
    WHERE COL1 = coalesce(var1, COL1) and
    COL2 = coalesce(var1, COL2)

    and locates the position by .9(count(COL3)+ 1) (I think this is the formula)

    and uses the cursor to absolute fetch the 2 data (one in nth position with
    and other from n+1 th position).
    If the modulus is 0, then it just returns the value in nth position, else it
    does further calculation and returns a scalar value.

    So there will be one value, like 90.000 for 90th percentile.


    What I want to do is to use the above UDF as subquery in Select statement so
    I don't have to manually feed in the value to the UDF (Some how make the
    paramters equal to the identifiers(columns) that is being selected in main
    query)

    Thank you



    "Vinodk" <com> wrote in message
    news:eGWTm$phx.gbl...
    I dont think if there is any problem in your statement ... It would be nice
    if you can tell us your output also ...

    --
    HTH,
    Vinod Kumar
    MCSE, DBA, MCAD
    SCT Software Solutions
    http://www32.brinkster.com/sqlvinod


    "Tkim" <com> wrote in message
    news:iFlRa.5524$prod.itd.earthlink.net... 


    Tkim Guest

Similar Threads

  1. Replies: 2
    Last Post: September 30th, 12:13 PM
  2. Replies: 0
    Last Post: August 23rd, 11:56 AM
  3. Replies: 0
    Last Post: August 2nd, 03:03 PM
  4. Replies: 2
    Last Post: July 17th, 07:27 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139