I have two queries that count the total of employees according to multiple conditions; the only thing that changes is the last two AND clauses; I don't know how I can return the results in the same query. First Query
SELECT
COUNT(*)
FROM
(
SELECT
E.NAME,
E.LAST_NAME,
E.BIRTH_DATE,
E.ID
FROM
EMPLOYEES E
WHERE E.BIRTH_DATE BETWEEN '2022-10-18 00:00:00' AND '2022-10-18 23:59:59'
AND E.NAME IS NOT NULL
AND E.LAST_NAME IS NOT NULL
GROUP BY E.NAME, E.LAST_NAME, E.BIRTH_DATE,E.ID
) AUX;
Second Query
SELECT
COUNT(*)
FROM
(
SELECT
E.NAME,
E.LAST_NAME,
E.BIRTH_DATE,
E.ID
FROM
EMPLOYEES E
WHERE E.BIRTH_DATE BETWEEN '2022-10-18 00:00:00' AND '2022-10-18 23:59:59'
AND E.NAME IS NULL
AND E.LAST_NAME IS NULL
GROUP BY E.NAME, E.LAST_NAME, E.BIRTH_DATE,E.ID
) AUX;
Expected output:
| total |
|---|
| 3 --first row |
| 5 --second row |
and E.ID = 1 AND E.ID = 100... assuming this is an employee id, how could a row have both an ID of 1 and 100? Does this query return anything? Should it beand E.ID in (1, 100)?unionthe results.