Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » Query help(query help)
Query help [message #826879] Thu, 22 March 2012 12:00 Go to next message
Jatinder Singh is currently offline Jatinder Singh
Messages: 1
Registered: March 2012
Junior Member
Hi Everybody,
I need one help regarding query to display data. I am using oracle 10g.

I have below table test1:


ID NAME SORTORDER PARENTID
---------------------------------------------------------------------
1 FRUIT 1
2 SPORT 2
12 ORANGE 1 1
22 RUGBY 2 2
23 MANGO 2 1
45 BASEBALL 1 2

For parent FRUIT, we have two child records ORANGE and MANGO and for parent SPORT, we have two child records RUGBY and BASEBALL. So we can say same table has both parent and chid records.

Right now i am querying like this to get this relation:

SELECT parent.name AS parentName, TT.name AS childName
FROM ( SELECT ID, name, sortorder
FROM TEST1
WHERE PARENTID IS NULL
GROUP BY ID, name, SORTORDER
ORDER BY SORTORDER) parent,
TEST1 TT
WHERE parent.ID = TT.PARENTID
ORDER BY parent.sortorder, TT.sortorder;

It give me result like this:

PARENTNAME CHILDNAME
--------------------------
FRUIT ORANGE
FRUIT MANGO
SPORT BASEBALL
SPORT RUGBY


I need result like this below such that we need only one column, which has first parent name then all childs and next parent then all childs:

NAME
--------------------------
FRUIT
ORANGE
MANGO
SPORT
BASEBALL
RUGBY


Please provide your suggestions and comments. I will greatly appreciate all your responses.
Please let me know if need any other info.

Regards
Dev
Re: Query help [message #826887 is a reply to message #826879] Thu, 22 March 2012 12:06 Go to previous message
Russell Bateman is currently offline Russell Bateman
Messages: 3052
Registered: July 2009
Location: Provo, Utah, USA
Senior Member

On 3/22/2012 10:00 AM, Jatinder Singh wrote:
> Hi Everybody,
> I need one help regarding query to display data. I am using oracle 10g.
>
> [snip]

I know it's confusing to many new to this forum especially given the
posts of recent days, but this just isn't a general, do-my-homework,
teach-me-Java, yada, yada, yada forum. This forum is here to answer
questions on and solve problems with how to install and use Eclipse.

If your question isn't about Eclipse, don't ask it here. Get off your
butt, fire up your browser and look for an appropriate forum.
Previous Topic:Integration of Eclipse BIRT with SAP Database
Next Topic:Eclipse Classic 3.7.2 version number confusion
Goto Forum:
  


Current Time: Thu Apr 17 08:44:21 EDT 2014

Powered by FUDForum. Page generated in 0.13897 seconds