We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now

x

# Nested query

on
Medium Priority
283 Views
I need the result of the two queries combined to give me one output with one list

SELECT distinct substr(parent,3) division
FROM wwglph2.wwgl_dv_tree
CONNECT BY prior child = parent
ORDER BY 1

returns:
AFD
E0X
INV
MIS
MXO
OSX
SAC
SCH
SER
SGA
SHD
STC
STD
STH
STX
SZH
USC
VER
XIO
ZBD

SELECT distinct substr(parent,3) division
FROM wwglph2.wwgl_dv_tree
CONNECT BY prior child = parent
ORDER BY 1

retruns :
INS
Comment
Watch Question

## View Solution Only

Top Expert 2006

Commented:
Hi,

try :
SELECT *
FROM (SELECT DISTINCT substr(PARENT, 3) division
FROM wwglph2.wwgl_dv_tree
CONNECT BY PRIOR child = PARENT
UNION ALL
SELECT DISTINCT substr(PARENT, 3) division
FROM wwglph2.wwgl_dv_tree
CONNECT BY PRIOR child = PARENT
ORDER BY 1

or
( not sure if this one will work )

SELECT DISTINCT substr(PARENT, 3) division
FROM wwglph2.wwgl_dv_tree
CONNECT BY PRIOR child = PARENT
ORDER BY 1

:)

Commented:
SELECT substr(parent,3) division
FROM wwglph2.wwgl_dv_tree
CONNECT BY prior child = parent
UNION
SELECT substr(parent,3) division
FROM wwglph2.wwgl_dv_tree
CONNECT BY prior child = parent
ORDER BY 1

Commented:

Select division from
(
SELECT distinct substr(parent,3) division
FROM wwglph2.wwgl_dv_tree
CONNECT BY prior child = parent
)
union all
Select division from
(
SELECT distinct substr(parent,3) division
FROM wwglph2.wwgl_dv_tree
CONNECT BY prior child = parent
)
ORDER BY 1
--You can also use union instead of union all depending on ur requirement

Not the solution you were looking for? Getting a personalized solution is easy.

##### Thanks for using Experts Exchange.

• View three pieces of content (articles, solutions, posts, and videos)
• Ask the experts questions (counted toward content limit)
• Customize your dashboard and profile