Rank Table Sales Setup with Sale

  • Hello DistinguishedThey could help me with this case, I have a column that shows the sales of each client. This is in a table. But I want to evaluate the result of the sale with another table that has the ranges of sales, which gives the level of it.

    Thanks

  • Your ranges have gaps: where would 500,000.50 fall?

    At any rate, something like:

    SELECT s.sales, ss.Nota
    FROM sales s
    LEFT OUTER JOIN sales_setup ss ON s.sales BETWEEN ss.rango_inf AND ss.rango_sup

    SQL DBA,SQL Server MVP(07, 08, 09) A socialist is someone who will give you the shirt off *someone else's* back.

  • ScottPletcher - Thursday, January 10, 2019 3:05 PM

    Your ranges have gaps: where would 500,000.50 fall?

    At any rate, something like:

    SELECT s.sales, ss.Nota
    FROM sales s
    LEFT OUTER JOIN sales_setup ss ON s.sales BETWEEN ss.rango_inf AND ss.rango_sup

    Thanks Very Much!!  I work perfectly!!

  • angelreynosog - Friday, January 11, 2019 1:21 PM

    ScottPletcher - Thursday, January 10, 2019 3:05 PM

    Your ranges have gaps: where would 500,000.50 fall?

    At any rate, something like:

    SELECT s.sales, ss.Nota
    FROM sales s
    LEFT OUTER JOIN sales_setup ss ON s.sales BETWEEN ss.rango_inf AND ss.rango_sup

    Thanks Very Much!!  I work perfectly!!

    It would except you didn't answer his question... you have gaps in your ranges... that needs to be repaired.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • Jeff Moden - Friday, January 11, 2019 2:11 PM

    angelreynosog - Friday, January 11, 2019 1:21 PM

    ScottPletcher - Thursday, January 10, 2019 3:05 PM

    Your ranges have gaps: where would 500,000.50 fall?

    At any rate, something like:

    SELECT s.sales, ss.Nota
    FROM sales s
    LEFT OUTER JOIN sales_setup ss ON s.sales BETWEEN ss.rango_inf AND ss.rango_sup

    Thanks Very Much!!  I work perfectly!!

    It would except you didn't answer his question... you have gaps in your ranges... that needs to be repaired.

    +1, but I don't think the OP gets it!

    ...

Viewing 5 posts - 1 through 4 (of 4 total)

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