sql statement notes

1. a table classified information, but also need another table field

SELECT A.KindID,A.ScoreAll,B.KindName FROM  (SELECT KindID,CAST(CAST(SUM(ABS(Score)) AS decimal)/100 AS decimal(18,2)) AS ScoreAll FROM RYTreasureDB.dbo.RecordDrawScore WHERE InsertTime BETWEEN  '2019-01-01' AND '2019-01-19 23:23:23' GROUP BY KindID )A
LEFT JOIN RYPlatformDB.dbo.MobileKindItem AS B
ON A.KindID = B.KindID;
 

The first select set out as a result of A, select and then once again be left join with Table B

 

2. The value of a table to another table update value

update  RecordDrawScore set KindID = RecordDrawInfo.KindID from RecordDrawInfo where RecordDrawInfo.DrawID = RecordDrawScore.DrawID;

Guess you like

Origin blog.csdn.net/qq_34326603/article/details/86552519