i have acheived similar result specfying OR condition with where clause, is that ok?
SELECT
*
FROM
(SELECT
t1.emp_no AS emp,
t2.dept_no AS dept,
(SELECT
emp_no
FROM
dept_manager
WHERE
emp_no = 110022) AS manager
FROM
employees AS t1
JOIN dept_emp AS t2 ON t1.emp_no = t2.emp_no
WHERE
t1.emp_no <= 10020
OR t1.emp_no = '110039'
GROUP BY t1.emp_no , t2.dept_no
ORDER BY emp) AS A
UNION SELECT
*
FROM
(SELECT
t1.emp_no AS emp,
t2.dept_no AS dept,
(SELECT
emp_no
FROM
dept_manager
WHERE
emp_no = 110039) AS manager
FROM
employees AS t1
JOIN dept_emp AS t2 ON t1.emp_no = t2.emp_no
WHERE
t1.emp_no BETWEEN '10021' AND '10040'
OR t1.emp_no = '110022'
GROUP BY t1.emp_no , t2.dept_no
ORDER BY emp) AS b
ORDER BY emp;
*
FROM
(SELECT
t1.emp_no AS emp,
t2.dept_no AS dept,
(SELECT
emp_no
FROM
dept_manager
WHERE
emp_no = 110022) AS manager
FROM
employees AS t1
JOIN dept_emp AS t2 ON t1.emp_no = t2.emp_no
WHERE
t1.emp_no <= 10020
OR t1.emp_no = '110039'
GROUP BY t1.emp_no , t2.dept_no
ORDER BY emp) AS A
UNION SELECT
*
FROM
(SELECT
t1.emp_no AS emp,
t2.dept_no AS dept,
(SELECT
emp_no
FROM
dept_manager
WHERE
emp_no = 110039) AS manager
FROM
employees AS t1
JOIN dept_emp AS t2 ON t1.emp_no = t2.emp_no
WHERE
t1.emp_no BETWEEN '10021' AND '10040'
OR t1.emp_no = '110022'
GROUP BY t1.emp_no , t2.dept_no
ORDER BY emp) AS b
ORDER BY emp;
0 answers ( 0 marked as helpful)
Submit an answer
related questions
Resolved:
Getting Null as the result from all stored procedure queries including the assignment too.