Results 1 to 6 of 6

Thread: Ranking

  1. #1
    Join Date
    Jun 2004
    Posts
    57

    Unanswered: Ranking

    My small number of brain cells prohibits me from figuring this out. I've got a table

    ProviderName EOPCode TotalDenied
    Memorial Hosp 66 $4,598
    Memorial Hosp A3 $2,133
    Memorial Hosp 22 $1,111
    Memorial Hosp 20 $912
    Memorial Hosp 39 $4,321
    Memorial Hosp b2 $62
    Parkdate Hosp b2 $6,251
    Parkdate Hosp 66 $2,346
    Parkdate Hosp 22 $1,252
    Parkdate Hosp 20 $4,056
    Stone Hosp V33 $8,059

    I need to output this table as below (with a denial rank for each hospital -- DESC sort on TotalDenied).
    I'm stuck on how to get the DenialRank column to work.

    ProviderName EOPCode TotalDenied DenialRank
    Memorial Hosp 66 $4,598 1
    Memorial Hosp 39 $4,321 2
    Memorial Hosp A3 $2,133 3
    Memorial Hosp 22 $1,111 4
    Memorial Hosp 20 $912 5
    Memorial Hosp b2 $62 6
    Parkdate Hosp b2 $6,251 1
    Parkdate Hosp 20 $4,056 2
    Parkdate Hosp 66 $2,346 3
    Parkdate Hosp 22 $1,252 4
    Stone Hosp V33 $8,059 1

    Appreciate the help.

    Ray

  2. #2
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    Code:
    Select	YourTable.ProviderName,
    	YourTable.EOPCode,
    	YourTable.TotalDenied,
    	count(*) as Rank
    from	YourTable
    	inner join
    		YourTable RankTable
    		on YourTable.Providername = RankTable.ProviderName
    		and YourTable.TotalDenied <= RankTable.TotalDenied
    If it's not practically useful, then it's practically useless.

    blindman
    www.chess.com: "sqlblindman"
    www.LobsterShot.blogspot.com

  3. #3
    Join Date
    Jun 2004
    Posts
    57

    Ranking part ii

    Order Counter.

    This is a relatively simple sql question. I am trying to add an order counter to a db. A given customer might have 10 orders.

    The table now simply has all the orders for that customer (and all the other customer orders).

    I am hoping to add a column that for customer A adds an OrderNumber (there is no ranking -- just a count). Then it spools to the next customer and starts over at OrderNumber = 1.

    Appreciate the help.

    Regards

    Ray

  4. #4
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    Why are you dredging up a thread that is nearly two years old?
    If it's not practically useful, then it's practically useless.

    blindman
    www.chess.com: "sqlblindman"
    www.LobsterShot.blogspot.com

  5. #5
    Join Date
    Jun 2004
    Posts
    57
    Blindman.
    I had a similar post to the previous one, and I didn't want you to think i was asking the same question twice -- and didn't pay attention to your earlier post.

    Ray

  6. #6
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    Go ahead and start a new thread. And also, please explain more clearly what your question is. Your post was kind of confusing, or I would have answered it anyway.
    If it's not practically useful, then it's practically useless.

    blindman
    www.chess.com: "sqlblindman"
    www.LobsterShot.blogspot.com

Posting Permissions

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