I am trying to get a column which specify the points by comparing the value from original table to min and max value from another table. I have a main table, which consists of few columns of values and the respective point column to be inserted. Here is the example:
I tried a few ways that i found in here, but most not as complex as mine so i have no idea how to move from here.
This is the code that i tried
SELECT a.User, a.Department, a.BU, a.Revenue, b.Point as Revenuepoint
FROM Sales a
JOIN Point b ON a.Revenue BETWEEN b.fromvalue and b.tovalue
2
Answers
Seems like both of your tables not joined correctly and condition should come after WHERE statement, there is no WHERE in your query. Try below code.
In below way you can add any column to the select (Column should be in a or b in your scenario)
Since you’re only looking for a.Revenue between b.fromvalue and b.tovalue`, there is no need to use union, Simple select query with the profit column will solve your problem.