Results 1 to 6 of 6
  1. #1
    Join Date
    Mar 2007
    Posts
    97

    Unanswered: Ntile with MySql

    Hello,

    is there a way to do Ntile with MySql? Maybe with stored Procedure or something else?

    If not, do you have an idea, how to simulate on Client-Side, using c# and ado?

    Thank you

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    yes, a stored procedure can do anything
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    Mar 2007
    Posts
    97
    Oh, that takes a load of my mind.

    I currently use the following expression in Sql Server

    Select year, quarter, price, ntile(3) over (partition by year, quarter order by price)

    to retrieve something like ABC Price-Ranges for each quarter.

    I don't know how much work it is, to simulate this in a stored procedure for MySql. Unfortunately I can't find any sample code on the Internet. This doesn't make me very confident.

    How many lines of Code will such a procedure have, about 10, 50 or maybe 100?

    Do you know any sample Code or can give me hint where to look at?

  4. #4
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    oh, i'd say it would have maybe somewhere between 9 and 37 lines of code, give or take

    the stored proc would run this query:
    Code:
    SELECT year, quarter, price
      FROM daTable
    ORDER
        BY year, quarter, price
    and then process the rows in sequence
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  5. #5
    Join Date
    Mar 2007
    Posts
    97
    And what about Sql-Function, is it possible to create such a Sql-Function, so I can use it in the select statement? Just like ntile for Sql Server.

  6. #6
    Join Date
    Mar 2007
    Posts
    97
    Not possible?

Posting Permissions

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