I have a SQL query which returns the total amount of issues:
[HTML]SELECT issue,Count(issue) as total FROM mytable Group by issue[/HTML]
This works but I need the total of the same catagory in three tables so I assumed a union would work so tried something like this:
[HTML]SELECT issue,Count(issue) as total FROM mytable Group by issue
Union
SELECT issue,Count(issue) as totalFROM mytable2 Group by issue
union
SELECT issue,Count(issue) as total FROM mytable3 Group by issue[/HTML]
the problem is that the issue are duplicated so I will not get the total count I am looking for.
current results:
[HTML]
issue total
headache 4
headache 30
headache 2
cough 5
cough 55
cough 5[/HTML]
wanted result:
[HTML]
issue total
headache 36
cough 65[/HTML]
I assumed I could simply add sum(total) but did not work. What is the correct way to do this?