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 2000 Forums
 SQL Server Development (2000)
 Array

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2006-04-26 : 09:22:58
Larry writes "Hello,

I hope this isn't too verbose...

In a similar manner to a map mileage chart, I have a lookup table of horizontal, and vertical rows/columns.

Where the two meet is the correct value.

I hava a database file set up as 1-85 down, and columns labeled 1-85 across.

For a given number, what SQL can be used (similar to a VLOOKUP in EXCEL)to find the meeting point value in the database.

Thank You very much. My brain hurts, and I feel like burnt toast."

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2006-04-26 : 11:03:41
Sql Server isn't a spreadsheet, it is designed to handle that problem in a different way. In your example you could have 3 columns (row, col, value).

EDIT:
something like this:

set nocount on
Create Table #mySpreadsheetTable
(row int
,col int
,value int)
go
insert #mySpreadsheetTable (row,col,value)
select 1,1,-1 union
select 1,2,-2 union
select 1,3,-3 union
select 1,4,-4 union
select 2,1,-5 union
select 2,2,-6 union
select 2,3,-7 union
select 2,4,-8 union
select 3,1,-9 union
select 3,2,-10 union
select 3,3,-11 union
select 3,4,-12 union
select 4,1,-13 union
select 4,2,-14 union
select 4,3,-15 union
select 4,4,-16


select value
from #mySpreadsheetTable
where row = 3
and col = 2

go
drop table #mySpreadsheetTable


--output:
value
-----------
-10


Be One with the Optimizer
TG
Go to Top of Page
   

- Advertisement -