Quantcast
Channel: Forum Getting started with SQL Server
Viewing all articles
Browse latest Browse all 7129

tricky update

$
0
0

I have a tricky update to make. Any help is highly appreciated. Thanks in advance for your help.

Here is the scenario as shown on the image attached. I have to update P_main.ver_key from Versions.verkey where P_main.ver_key is null. The logic is to get the ver_key for that pid where Versions.pcmm<=max(P_main.vdmm). The values that should be populated in the null spots are shown in the 'after update' column on the image.

example:

P_main table:

pid = 50000178

vcmm= 2014027001

Versions table:

pid = 50000178

max pdmm <=2014027001 is 2014032000

therefore update ver_key = 154



sample data


Viewing all articles
Browse latest Browse all 7129

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>