CodePudding user response:
insert into b (field name)
The select val
The from (
Select *
From a
Unpivot (val for col (station, cause)) in p
) a
Where not the exists (1 from the select top 1 b where the field name=Dr. Al)
Both post and post bar
CodePudding user response:
Insert into table b (station, cause)
The select a.s tation, a.c ause
A. the from list a
Left the join table b b
On a.s tation=b.s tation
And a.c ause=biggest ause
Where b.s tation is null
CodePudding user response:
The MERGE INTO target b
USING a source
ON (target) station=source) station AND target. Cause=source. The cause)
WHEN NOT MATCHED THEN
INSERT (station, cause) VALUES (source) station, the source, cause);
CodePudding user response: