8 回答

TA貢獻(xiàn)1872條經(jīng)驗(yàn) 獲得超4個(gè)贊
select * from A inner join (select table1.* from b table1 inner jioin b table2 on table1.a1 = table2.a1 and table1.Time>table2.Time) tableB inner join?on A.a1=tableB.a1

TA貢獻(xiàn)1803條經(jīng)驗(yàn) 獲得超3個(gè)贊
select * from A as a left join (select * from B where B.Time in (select MAX(B.Time) as Time from B group by B.a1)) as b on a.a1=b.a1

TA貢獻(xiàn)1874條經(jīng)驗(yàn) 獲得超12個(gè)贊
SELECT A.*, B2.* FROM A
CROSS APPLY
(
SELECT TOP 1 B.*
FROM B
WHERE B.a1 = A.a1
Order by B.Time Desc
) B2

TA貢獻(xiàn)1824條經(jīng)驗(yàn) 獲得超5個(gè)贊
可以使用with as
WITH temp AS
(
SELECT MAX(UpdateTIME) AS updatetime,a1 FROM? dbo.tableb? GROUP BY Question
)
SELECT * FROM dbo.tablea
INNER JOIN temp ON dbo.tablea.a1 = temp.a1
- 8 回答
- 0 關(guān)注
- 578 瀏覽
添加回答
舉報(bào)