Is this possible in SQL? It seems like a simple concept. (I'm using SQL Server 2005)
Loop through all the rows in my SQL table compare the values in column m if one row =65 and the next equals 120 increase j, and print that value in another column (column q)
Sub InsertProductionCycle()
Dim LR As Long
Dim j As Integer
j = 1
LR = Range("G" & Rows.Count).End(xlUp).Row
For i = 1 To LR Step 1
Cells(i, "Q").Value = j
If Cells(i, "M").Value = 65 And Cells(i + 1, "M").Value = 190 Then
j = j + 1
End If
Next i
End Sub
Any thoughts from the SQL experts? Can I do this in SQL? My thoughts about this is: Perhaps the loop is a bit of a stretch, (I can run that in a sql job), but can you compare the rows and insert the j loop value in another column. Thats where I'm stuck.