Skip to content
Advertisement

Value from 2nd Row of column copied to 1st row of next column

The table looks like below.

I am trying to make 1 new column say SuprerFrez whose value is depends on column FREQHZ.

For every UVRID group 2nd value FREQHZ will be 1st value of SuprerFrez and for last FREQHZ, SuprerFrez value will be zero.

Expected output with 1 new column whose value depends upon FREQHZ column. Order by FREQHZ ASC

Advertisement

Answer

You are looking for lead():

Note this assumes that the ordering is by DynamoNo. If that is not the ordering you have in mind, then you need another column that specifies the ordering. For instance, if you wanted “insert” order, you could use an identity column:

Then the code would look like:

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement