D
dandc0711
I have a table that looks like the following
RUNID | DATETIME | PROCESS
0001 1/1/09 1201 Neck
0001 1/1/09 1202 Neck
0001 1/1/09 1203 Neck
0001 1/1/09 1204 Neck
0001 1/1/09 1205 Neck
0001 1/1/09 1206 Body
0001 1/1/09 1207 Body
0001 1/1/09 1208 Body
0001 1/1/09 1209 Body
0001 1/1/09 1210 Neck
0001 1/1/09 1211 Neck
0001 1/1/09 1212 Neck
0001 1/1/09 1213 Neck
0001 1/1/09 1214 Body
0001 1/1/09 1215 Body
0001 1/1/09 1216 Body
0001 1/1/09 1217 Body
0001 1/1/09 1218 Shutdown
I need to make a query that only displays the recrods before and after a
change in the process field. So where it changes from Neck to Body I want to
see the Last Neck and the first Body. So the above table would ideally yeild
something like the following.
RUNID | DATETIME | PROCESS
0001 1/1/09 1201 Neck
0001 1/1/09 1205 Neck
0001 1/1/09 1206 Body
0001 1/1/09 1209 Body
0001 1/1/09 1210 Neck
0001 1/1/09 1213 Neck
0001 1/1/09 1214 Body
0001 1/1/09 1217 Body
0001 1/1/09 1218 Shutdown
I tried to use a Group By but it just lumped all the necks together and and
all the Bodies together, which doesn't work for my needs since I need to be
able to see the datetimes when it changes each time.
Thanks for the help
RUNID | DATETIME | PROCESS
0001 1/1/09 1201 Neck
0001 1/1/09 1202 Neck
0001 1/1/09 1203 Neck
0001 1/1/09 1204 Neck
0001 1/1/09 1205 Neck
0001 1/1/09 1206 Body
0001 1/1/09 1207 Body
0001 1/1/09 1208 Body
0001 1/1/09 1209 Body
0001 1/1/09 1210 Neck
0001 1/1/09 1211 Neck
0001 1/1/09 1212 Neck
0001 1/1/09 1213 Neck
0001 1/1/09 1214 Body
0001 1/1/09 1215 Body
0001 1/1/09 1216 Body
0001 1/1/09 1217 Body
0001 1/1/09 1218 Shutdown
I need to make a query that only displays the recrods before and after a
change in the process field. So where it changes from Neck to Body I want to
see the Last Neck and the first Body. So the above table would ideally yeild
something like the following.
RUNID | DATETIME | PROCESS
0001 1/1/09 1201 Neck
0001 1/1/09 1205 Neck
0001 1/1/09 1206 Body
0001 1/1/09 1209 Body
0001 1/1/09 1210 Neck
0001 1/1/09 1213 Neck
0001 1/1/09 1214 Body
0001 1/1/09 1217 Body
0001 1/1/09 1218 Shutdown
I tried to use a Group By but it just lumped all the necks together and and
all the Bodies together, which doesn't work for my needs since I need to be
able to see the datetimes when it changes each time.
Thanks for the help