Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 control table

Author  Topic 

akpaga
Constraint Violating Yak Guru

331 Posts

Posted - 2011-08-09 : 11:16:45
Hi all

I have a table Customers in the following data

Customer_Type, Max_value , Points

Regular , 1, 100
Regular ,5,50
Regualr,15,25
Monthly,20,500
Monthly,10,100
Monthly,5,50

max value 1 means it is a range 0-1
max value 2 means range 2-5 so so onn


i wnat to use this table as control table

So when i have a value 3 for regualr customer his score is 50 since it falls betweenn 2-5 and max_value 5 is 50

How can i compare the value of 3 wih max vlaue to get the score...

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-08-09 : 12:21:57
something like

SELECT TOP 1 *
FROM Table
WHERE Max_Value >= @value
AND Customer_Type = @type
ORDER BY Max_Value ASC


pass suitable values for @type and @value to get max value record

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -