Reputation: 135
Basically I have 2 selects which shows counts:
select count(b.i_connection_type) as Incoming_calls
from (select i_connection
from Active_Calls
where i_connection is not NULL ) as a
join Connections as b on a.i_connection=b.i_connection
where b.i_connection_type=2;
select count(*) as "On-Net Calls" from Active_Calls where i_connection = 1;
How to just stick them together, so it will be one table like:
|On-Net Calls| Incoming Calls|
-------------------------------
| 2 | 4 |
Upvotes: 0
Views: 37
Reputation: 19224
Your queries return one integer each, which can be projected on a single row like:
select (select 1) as a, (select 2) as b;
+---+---+
| a | b |
+---+---+
| 1 | 2 |
+---+---+
So, simply nest the two queries in a new one:
select (
select count(b.i_connection_type) from (
select i_connection from Active_Calls
where i_connection is not NULL ) as a
join Connections as b on a.i_connection=b.i_connection
where b.i_connection_type=2
) as "Incoming Calls", (
select count(*) from Active_Calls where i_connection = 1
) as "On-Net Calls";
Upvotes: 1