I have a table that has a column with 15 distinct names (TotalName) in it two of those names would be flowOne and flowTwo. There is also a column that is a timestamp (t\_stamp) and Value. Every time a new value is added to the table it is timestamped along with where it came from. I am trying to create a query that will give me columns for each of the 15 distinct names along with a total for the month and the month number. I have tried it for two of the names and they end up on separate rows. I would like to have it show up all on the same row for the month.

```
SELECT  YEAR(t_stamp) as 'Year', MONTH(t_stamp) as 'Month', sum(FlowTotals.FlowTotal) as 'flowOne', '' as 'flowTwo'
FROM DataBase.dbo.FlowTotals
WHERE FlowTotals.TotalName = 'flowOne'
    and year(t_stamp) = year(getDate())
Group By Year(t_stamp), Month(t_stamp)

UNION

SELECT  YEAR(t_stamp) as 'Year', MONTH(t_stamp) as 'Month', '' as 'flowOne', sum(FlowTotals.FlowTotal) as 'flowTwo'
FROM DataBase.dbo.FlowTotals
WHERE FlowTotals.TotalName = 'flowTwo'
    and year(t_stamp) = year(getDate())
Group By Year(t_stamp), Month(t_stamp)

```

Order by Month

This puts out

```
Year   Month   totalOne   totalTwo
2019     1     123456     0
2019     1     0          789123
2019     2     456789     0
2019     2     0          345678

```

I would like to have one row for month 1 one row for month 2 with all values on that row etc.

I know that part of the problem is I have '' as 'flowOne in my Select statements but that was the only way I could think of to separate into 2 different columns. The summing for each row is working as expected.