I believe I have formatted my query incorrectly but my Google skills haven't come up with a solution that works. This is my query:

```
use movement;
select t1.StoreNumber, t1.saleDate, t1.departmentNumber, sum(t1.dollarsSold), sum(ifnull(t2.loss,0))
from movement.movement t1
left join knownLoss.producekl t2 ON t1.StoreNumber = t2.Store
where t1.StoreNumber = 3
AND (t1.departmentNumber = 10 OR t1.departmentNumber = 20 OR t1.departmentNumber = 27 OR t1.departmentNumber = 30 OR t1.departmentNumber = 40 OR t1.departmentNumber = 50 OR t1.departmentNumber = 51 OR t1.departmentNumber = 60 OR t1.departmentNumber = 70 OR t1.departmentNumber = 80 OR t1.departmentNumber = 81 OR t1.departmentNumber = 82 OR t1.departmentNumber = 90 OR t1.departmentNumber = 95 OR t1.departmentNumber = 96 OR t1.departmentNumber = 97)
AND t1.saleDate > date_sub(curdate(), interval 7 day)
group by t1.saleDate, t1.StoreNumber, t1.departmentNumber;

```

My intended output is to give a table grouped by date of sale, store, and department summing sales totals and sales losses in the final two columns

My expected output should look like this:

```
-------------------------------------------------------------
| Store Number | Sale Date | Dept Num | Dollars Sold | Loss |
-------------------------------------------------------------
|      1       | 2017-3-9  |    10    |    7435.26   | 0.00 |
-------------------------------------------------------------
|      1       | 2017-3-9  |    20    |    30.50     | 3.00 |
-------------------------------------------------------------
|      1       | 2017-3-10 |    10    |    2503.22   | 4.00 |
-------------------------------------------------------------
|      2       | 2017-3-11 |    10    |    5685.49   |17.50 |
-------------------------------------------------------------
|      3       | 2017-3-9  |    10    |    75.26     | 4.55 |
-------------------------------------------------------------
|      4       | 2017-3-9  |    10    |    7435.26   | 0.00 |
-------------------------------------------------------------
|      4       | 2017-3-13 |    30    |      20.45   | 1.99 |
-------------------------------------------------------------

```

Instead of my expected output the loss column the loss column is all zeroes.

```
-------------------------------------------------------------
| Store Number | Sale Date | Dept Num | Dollars Sold | Loss |
-------------------------------------------------------------
|      1       | 2017-3-9  |    10    |    7435.26   | 0.00 |
-------------------------------------------------------------
|      1       | 2017-3-9  |    20    |    30.50     | 0.00 |
-------------------------------------------------------------
|      1       | 2017-3-10 |    10    |    2503.22   | 0.00 |
-------------------------------------------------------------
|      2       | 2017-3-11 |    10    |    5685.49   | 0.00 |
-------------------------------------------------------------
|      3       | 2017-3-9  |    10    |    75.26     | 0.00 |
-------------------------------------------------------------
|      4       | 2017-3-9  |    10    |    7435.26   | 0.00 |
-------------------------------------------------------------
|      4       | 2017-3-13 |    30    |      20.45   | 0.00 |
-------------------------------------------------------------

```

Even though when I query t2 alone it returns results

```
use knownLoss;
select t2.Store, t2.Department, t2.klDate, sum(t2.loss)
from producekl t2
group by klDate, Store, Department;

```

So my join must be messed up but I can't figure out how. Any ideas?