Sqlserver
 sql >> Database >  >> RDS >> Sqlserver

Come eseguire un inner join sul numero di riga in SQL Server

prova questo:

USE ROW_NUMBER() funzione in sql server 2008

select A.val,B.val 
from(
    SELECT val,row_number() over (order by val) as row_num
    FROM A)A
join
    (SELECT val,row_number() over (order by val) as row_num
    FROM B)B
on  A.row_num=B.row_num
ORDER BY A.val,B.val


Demo di violino SQL