I have a task to write a query who will list all data from multiple tables.
So i have:
Table1 with ID and some other columns Table2 with ID, ID_ Table1 and some other columns Table3 with ID and some other columns. But Table3 is not related with the other two tables. Also number of rows are not the same.
So i need to get a result like this:
column from Table3, column from Table2 and new column which i will get if I compare the results from Table3 and Table2.
I ve done that with this code, but i dont know how to join the tables:
SELECT [ColumnFromTable3],
CASE
WHEN [ColumnFromTable3] IN ('0001', '7004', '1004', '7001', '8001', '7014', '7012', '7015', '7006') THEN 'R1'
WHEN [ColumnFromTable3] IN ('9001', '9017') THEN 'R2'
WHEN [ColumnFromTable3] IN ('9003', '9006') THEN 'R3'
WHEN [ColumnFromTable3] IN ('9005', '9008', '9004') THEN 'R4'
ELSE 'OTHER'
END AS [NewColumn3]
FROM [dbo].[Table3]
The problem is that Table3 is not related with any other table and i need one column from that table.
Can you please suggest me how can i solve this. Thank you