Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

IDS SQL

Status
Not open for further replies.

747576

Programmer
Jun 18, 2002
97
GB
Hi I have a table of data:

ID Type FROM TO
a1 A 0 15
a1 B 15 25
a1 A 25 30
a1 A 30 65
a1 B 65 67

which I would like to query. The result I would like is to see what metres fall within a range, as below:

ID Type 0-10 10-20 20-30 30-40 40-50 50-60 60-70
a1 A 10 5 5 10 10 10 5
a1 B 5 5 2


Can I use the IDS/SID functions or is there already a function that can do this query.

Thank you

Code:
drop table #temp
create table #temp (ID varchar(5),[Type] varchar(20), from_m numeric, to_m numeric)

insert into #temp(ID,[Type],from_m,to_m)
values('a1','A','0','15')
insert into #temp(ID,[Type],from_m,to_m)
values('a1','B','15','25')
insert into #temp(ID,[Type],from_m,to_m)
values('a1','A','25','30')
insert into #temp(ID,[Type],from_m,to_m)
values('a1','A','30','65')
insert into #temp(ID,[Type],from_m,to_m)
values('a1','B','65','67')

select * from #temp
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top