[thelist] Query Question: Order By, Group By, or Sub Query?
Luther, Ron
Ron.Luther at hp.com
Wed May 31 13:01:37 CDT 2006
Casey Crookston asked a sort question:
>>We want the results to look like this:
>>
>>
>>
>>ID Parent ID Title
>>
>>----------------------------------------------
>>
>>1 Title1
>>
>>2 1 Title1a
>>
>>4 1 Title1b
>>
>>3 Title2
Hi Casey,
In Oracle I think the following would put the data in the right order:
Select ID, Parent_ID, NVL(Parent_ID, ID) as BigSort, Title from CC_Table
Sort by BigSort, ID
Then you would suppress 'BigSort' from your display. (Can't remember
off
the top if you can sort by a computed field that isn't part of the
select
or not. <shrug />)
Not sure how that translates for other db's.
HTH,
RonL.
More information about the thelist
mailing list