'How to join tables without key in SQL
I would like to join Table A and Table B, but there is no related key. And, Table C is my expected result table.
I have tried to use ROW_NUMBER(), but it did not serve my expectation. Below is my current code.
SELECT TableA.CustoemerId as CustoemerId, TableB.RewardCode as RewardCode,
ROW_NUMBER() OVER (ORDER BY TableA.CustoemerId) as TableA_RowNumber,
ROW_NUMBER() OVER (ORDER BY TableB.RewardCode) as TableB_RowNumber
FROM TableA
JOIN TableB ON TableA_RowNumber = TableB_RowNumber
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|

