Question: New to SQL.

I have two SQL tables T1 and T2 which looks like the following

```
T1
customer_key X1 X2 X3
1000         60 10  2018-02-01
1001         42 9   2018-02-01
1002         03 1   2018-02-01
1005         15 1   2018-02-01
1002         32 2   2018-02-05

T2
customer_key A1 A2 A3
1001         20 2  2018-02-17
1002         25 2  2018-02-11
1005         04 1  2018-02-17
1009         02 0  2018-02-17

```

I want to get T3 as shown below by joining T1 and T2 and filtering on T1.X3 = '2018-02-01'
and T2.A3 = '2018-02-17'

```
T3
customer_key X1    X2 
1000         60    10
1001         42    9
1005         15    1
1009         null null

```

I tried doing full outer join in the following way

```
create table T3
AS
select T1.customer_key, T3.customer_key, T1.X1, T1.X2
from T1
full outer join T2
on T1.Customer_key = T2.customer_key 
where T1.X3 = '2018-02-01' and T2.A3 = '2018-02-17'

```

It returns lesser number of rows than the total records that satisfying the where clause. Please advice

Answer: 
Full outer join with filtering is just confusing. I recommend filtering in subqueries:

```
select T1.customer_key, T3.customer_key, T1.X1, T1.X2
from (select t1.*
      from T1
      where T1.X3 = '2018-02-01'
     ) t1 full outer join
     (select t2.*
      from T2
      where T2.A3 = '2018-02-17'
     ) t2
     on T1.Customer_key = T2.customer_key ;

```

Your filter turns the outer join into an inner join. Moving the conditions to the `on` clause returns all rows in both tables -- but generally with lots of `null` values. Using `(T1.X3 = '2018-02-01' or t1.X3 is null) and (T2.A3 = '2018-02-17' or T2.A3 is null)` doesn't quite do the right thing either. Filtering first is what you are looking for.
When you join tables via `FULL OUTER JOIN`, the query engine finds all matched records (`INNER JOIN`) and also add any unmatched records from both tables to the `JOIN` result set. The latter have `NULL`s in all columns for the other table.

So for example, `customer = 1000` in `T1` will be included in the `JOIN` result although there is no such customer in `T2` but all columns from `T2` will be `NULL` (because of `FULL OUTER`). Then, when you apply a `WHERE` clause on these records (`WHERE` is executed after `JOIN` operations) your result set will EXCLUDE `customer = 1000` because `T2.A3 = '2018-02-17'` will fail (because `T2.A3` is `NULL` for `customer = 100`).

I couldn't provide a query to your question because your explanation is lacking what you are trying to accomplish and I couldn't make sense of your result set: why `customer = 1000` included but not `customer = 1002` for example. Please describe what you're trying to accomplish.

Depending on what you're trying to accomplish, you can move part of your `WHERE` clause to `JOIN` or use filters like `T1.customer is NULL` / `T1.customer is NOT NULL` to identify cases where records didn't match / did match and filter exactly what you need.