Let’s assume I two tables GOOD and BAD that stores records for widget production. My tables look like this
Widget Good
----------------
Widget A Y
Widget A Y
Widget B Y
Widget Bad
----------------
Widget A Y
Widget B Y
I have these two basic queries
select count(*) as good from table_good where widget = 'Widget A' and Good = 'Y'
select count(*) as bad from table_bad where widget = 'Widget A' and Bad = 'Y'
These would result in two tables like this
good
----
2
bad
---
1
I would like to combine these into a single query where I would get back a table with a single record that looks like this
good bad
-----------
2 1
Can someone point me how to do this. I thought doing a union and setting up fake columns in the other tables selects would do it, but I got the right table schema back, but had two seperate records.
Thanks!
Try this: