sql - Insert distinct entries from column x of Table A and column y of Table B into two columns in Table C -
i trying insert distinct combination of flowmeter
column of table a
, recordtime
column of table b
table c
ensuring no such combination selected.
query should avoid inserting select query output table c
if combination found in table c
using where
clause.
i have written below script seems not working. distinct filter filtering distinct entries 2 joined tables:
insert c (meterid,presrectimestamp,presunits,presval) select distinct a.flowmeter, b.recordtime, substring(b.formattedvalue, charindex(' ',b.formattedvalue)+1, len(b.formattedvalue)), substring(b.formattedvalue, 1, charindex(' ',b.formattedvalue)-1) b inner join on a.id = b.id not exists (select * c c.meterid = a.flowmeter , c.presrectimestamp = b.recordtime)
appreciating much.
Comments
Post a Comment