robert.hemley (9/11/2012)
I am completely new to SQL server i know a few of the basics. I have a VS2010 asp.net c# application with two dropdown listboxes and a textbox. I need to calculate the numbers e.g 3 + 3 = Medium, using the table below to calculate the answer so i can insert the output value into a textbox. Could anyone please help ?Regards Rob
Table
1 2 3 4 5
1Cold Cold Cold Cold HOT
2Cold Cold Cold Medium HOT
3Cold MediumMediumHOT HOT
4MediumMediumMediumHOT HOT
5MediumMediumMediumHOT HOT
Drop down Listbox3Drop down Listbox3
TextBox output =Medium
My preference for this one would be to use a lookup table. I'd then use the 'rowkey' and 'colkey' to lookup the resulting text to display.
create table lookup
(
rowkey int,
colkey int,
display varchar(10)
)
insert into lookup values (1,1,'Cold')
insert into lookup values (2,1,'Cold')
insert into lookup values (3,1,'Cold')
insert into lookup values (4,1,'Medium')
insert into lookup values (5,1,'Medium')
insert into lookup values (1,2,'Cold')
insert into lookup values (2,2,'Cold')
insert into lookup values (3,2,'Medium')
insert into lookup values (4,2,'Medium')
insert into lookup values (5,2,'Medium')
insert into lookup values (1,3,'Cold')
insert into lookup values (2,3,'Cold')
insert into lookup values (3,3,'Medium')
insert into lookup values (4,3,'Medium')
insert into lookup values (5,3,'Medium')
insert into lookup values (1,4,'Cold')
insert into lookup values (2,4,'Medium')
insert into lookup values (3,4,'Hot')
insert into lookup values (4,4,'Hot')
insert into lookup values (5,4,'Hot')
insert into lookup values (1,5,'Hot')
insert into lookup values (2,5,'Hot')
insert into lookup values (3,5,'Hot')
insert into lookup values (4,5,'Hot')
insert into lookup values (5,5,'Hot')
-- then when fetching text
select display as text_to_display
where rowkey = @rowkey and colkey = @colkey
Might not be as applicable as your decision table grows in size, but just an idea!