April 19, 2007 at 4:33 pm
I am very bad with working things.. soo i am going to try to show what i need....
Select * from tblPole
*************************************************
| PoleID Info on the Pole |
| ------ ---------------- |
| 111111 Some pole info 1 |
| 222222 Some pole info 2 |
| 333333 Some pole info 3 |
*************************************************
Select * from tblAttach where PoleID = 222222 Order by AttachHeight
*********************************************************
| AttachID PoleID AtHeight |
| -------- ------ -------- |
| 12396252 222222 304 |
| 12365632 222222 292 |
| 14589632 222222 279 |
*********************************************************
I am trying to get the distance between attachID #######
and the attachID above it if one exist. See below
*************************************************
| AttachID PoleID AtHeight Sep |
| -------- ------ -------- ----|
| 12396252 222222 304 -- |
| 12365632 222222 292 12 |
| 14589632 222222 279 13 |
*************************************************
Is this possible? could someone point me in the right direction?
My boss wants to try to keep the work in SQL Sever and not on my webiste if that is possible.
April 19, 2007 at 4:59 pm
Left join table tblAttach to itself on A1.PoleID = A2.PoleID and A1.AtHeight < A2.AtHeight
_____________
Code for TallyGenerator
April 20, 2007 at 7:01 am
I am not sure if i understand... it only seemed to add an extra row at the end that is the same as the row above it...
April 20, 2007 at 7:27 am
Try it.
Reading of this topic
http://www.sqlservercentral.com/forums/shwmessage.aspx?forumid=8&messageid=358909
will probably help you.
_____________
Code for TallyGenerator
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply