Hi CK,
thanks for the advice.
I ended up using a temp table to store the returned records and then a neat little trick i found to add a increment which is:
declare @intCounter int
set @intCounter = 0
update #Temp
SET @intCounter = rank = @intCounter + 1
thanks again
User Profile
Collapse
-
hi there,
i am not too sure about that for this reason:
X Y rank
-34.020559 18.348137 1
-34.041561 18.369392 1452
-34.035796 18.361704 2470
if you look at the rank the second row has an id that is 1451 bigger that the previous id. The subqeury say "bring back a count of all ids that are less than or equal to the current id"
Am i mistaken?...Leave a comment:
-
Create a dynamically incremented field
Hi,
Does anyone know how i could add a incrementing field to a select statement.
at the moment i have the following:
SELECT X,Y,
(SELECT COUNT(*)
FROM dbo.tbldo e2
WHERE e2.doid <= dbo.tblDO.doID) AS rank
from dbo.tblDO INNER JOIN
dbo.tblMA_XY ON dbo.tblDO.doID = dbo.tblMA_XY.do ID INNER JOIN
dbo.tblMA_MA ON dbo.tblMA_XY.MA _MAIN_ID = dbo.tblMA_MA.MA _MAIN_ID... -
-
update with a one to many
Hi,
I am trying to do the following
update table A with the latest record from table B.
TABLE A has
PID (primary key)
ID
YEAR
TABLE B is the same as above. There is a one to many relationship from A to B based on the ID.
I ran the following update and it worked but it took the first record for each ID in TABLE B and updated that to TABLE A. Instead, i...
No activity results to display
Show More
Leave a comment: