I have 3 independent querys that I would like to sum the values obtained in each query. These querys obtain a count value for each day of a month:
query one
day|val|
1 | 2
2 | 6
3 | 5*
4 | 2
5 | 7
query 2
day|val|
2 | 1
3 | 5*
10 | 5
11 | 2
12 | 7
I am using the instruction:
select day, SUM(val)
from query1 UNION query2
group by day
I found out that when a value is repeated instead of sum it would use one of the repeated values, for axample the days number 3 both have value 5. the instruction would give onlye value 5 instead of 10.
This is supposed to give me a report of total of values per day in a month but the report is wrong because of this problem caused by UNION How can i fix it?