I have two tables, Table1 and Table2.
Table1 has the following columns
- date
- u_id
- t_id
- col_t1_a
- col_t1_b
- col_t1_c
and Table2 has the following columns
- date
- ux_id
- tx_id
- col_t2_a
- col_t2_b
- col_t2_c
Table1.u_id is a sub-string of Table2.ux_id and Table1.t_id = Table2.tx_uid.
I am trying to get all the columns (col_t2_c) from Table2 when all the below conditions are true
- Table1.t_id = Table2.tc_uid and
- substring(Table2.ux_id,7,6) = Table1.u_id and
- Table1.date = Table2.date = 'yymmdd' and
- Table1.col_t1_a = 'A' and
- Table1.col_t1_b = 'B' and
- Table1.col_t1_c = 'C'
I need some help in writing a SQL Server 2008 query to achieve the above.
Any help will be grateful.