I’m having trouble with a query I’m trying to write in oracle.
Basically I want to get the count of two tables that have the same provider list. I can run the query individually but not sure how to do it in one shot.
Here’s a example:
SELECT name, COUNT(name)
FROM table1
group by name
This gives me a list of names and a count beside them. If I run the same command but on table2(changing the from statement), it works fine. What I want to do is have a query that takes count from table1 and substracts it from count from table2.
How can I do it? I have tried to do nested selects and so on but can’t seem to get it to work.
One option assuming that the
namevalues in both tables are identical would beIf you want to handle the case where one table has a
namethat the other doesn’t but you don’t know which table has the extra name (and assuming that you want to say that the other table has acntof 0 for thatname)which you can see in this SQLFiddle