Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Test Link samll Data
create table Las(name nvarchar(50), Depth int); insert into Las values('testName1', 25); insert into Las values('testName2', 76); insert into Las values('testName3', 31); insert into Las values('testName4', 24); create table Calci(name nvarchar(50), Depth int, carbon int, calcium int); insert into Calci values('testName1', 24,30,10); insert into Calci values('testName1', 30,25,15); insert into Calci values('testName1', 31,24,16); insert into Calci values('testName2', 75,25,15); insert into Calci values('testName2', 80,24,16); insert into Calci values('testName2', 85,28,25); /*select * from Las select * from Calci*/ select t1.name,t1.Depth,q.carbon,q.calcium from Las t1 outer apply ( select top 1 carbon,calcium from Calci t2 where t2.name=t1.name and t2.Depth>t1.Depth -- From all the highest,.... order by t2.Depth asc -- get the smaller )q
run
|
edit
|
history
|
help
0
Update Temp table to Insert node in XML data using SQL
DDL,DQL,DML
New
Hospital
Stuff
a
Return a single column that matches a parameter
do several updates at once
STACK
sql 7