I would like to know what sentence would allow me to obtain the total number of patients (table 1) and doctors (table 2) in the same select.
In a practical case, I have 9 patients and 5 doctors. You should be able to count on the same statement, the records of the two tables and obtain a result of 14.
I have used
select count(pacnombres) from pacientes union select count(mednombres) from medicos;
But it gives me 2 rows, the first with 9 (equivalent to patients) and another with 5 (equivalent to doctors).
I have also used
select count(pacnombres and mednombres) from pacientes, medicos;
But what it is doing is multiplying 9 * 5 and it gives me 45 xD
Aid!
Your query must formulate as follows:
In this way, the sum of both counts should appear correctly.
The simplest is to use the subqueries at the column level:
combined would be:
Clarification, this is possible, because each subquery returns a single value.
you could do it this way
Apparently it is not optimal but it works :)