Quantcast
Channel: SQL Server Integration Services forum
Viewing all articles
Browse latest Browse all 24688

sql

$
0
0

hey,

I have a task where in I have a source table with id, createtime and binary column.

Destination table also has same structure. The task is to update the binary column in destination table based on latest time in source.

id is not primary key. It may repeat and can have multiple records with same Id in both the table.

example

source table 

id                   createtime              binary

101               8/9/2018 13:53          0

101               8/9/2018 15:15          1

102               8/9/2018 10:10          1

destination table

id                   createtime              binary

101               8/9/2018 15:10          0

101               8/9/2018 15:17          0

102               8/9/2018 10:15          0

here in destination table id 101 has 2 entries. it should get the difference in  id row's createtime and if its less than 10(in this case the lastest row is with time 15:17) should update value of binary in destination table to 1. the time with 15:10 should be set to 0.

How can I do it in sql?? Please help!!

                 

Viewing all articles
Browse latest Browse all 24688

Trending Articles



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