Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> Brain cramp on analytical functions and grouping.

Brain cramp on analytical functions and grouping.

From: Jesse, Rich <Rich.Jesse_at_qtiworld.com>
Date: Wed, 07 Aug 2002 10:34:44 -0800
Message-ID: <F001.004ADD76.20020807103444@fatcity.com>


OK, my brain hurts. A dev wants a query to return in a peculiar sort order on 8.1.7.2, but I'm having no luck. He needs groups of rows sorted by the whole of their key values. That doesn't sound right, so maybe an example:

Table A

RI	WO		CP		RC	RN
1	W859674      	A120003     	3	1
2	W859674      	A120004     	3	2
3	W859674      	A120006     	3	3

4	W838796      	A120000     	2	1
5	W838796      	A120003     	2	2

6	W844656      	A120000     	2	1
7	W844656      	A120004     	2	2

8	W849769      	A120000     	2	1
9	W849769      	A120004     	2	2

10	W858835      	A120000     	2	1
11	W858835      	A120003     	2	2

12	W880717      	A120003     	2	1
13	W880717      	A120006     	2	2

In an attempt to breakdown the problem, I added columns RC and RN as "COUNT(*) OVER (PARTITION BY WO)" and "ROW_NUMBER() OVER (PARTITION BY WO ORDER BY CP)", respectively. I also added the row spacing here for clarity.

The dev would like the group of WO W858835, rows 10 and 11, immediately after WO group W838796 because the groups have the same number of rows (RC) and same values of CP within the groups.

MIN and MAX would work in this case, but if the groups are larger than two it's no guarantee of order. What I was thinking is a report column that would be the concatonation of all the CPs for the group, but since it's VARCHAR2 and not numeric, I'm not sure how that could be accomplished.

Any suggestions, including favorite beers, is more than welcome.

TIA!

Rich Jesse                           System/Database Administrator
Rich.Jesse_at_qtiworld.com              Quad/Tech International, Sussex, WI USA

--

Please see the official ORACLE-L FAQ: http://www.orafaq.com
--

Author: Jesse, Rich
  INET: Rich.Jesse_at_qtiworld.com
Fat City Network Services    -- (858) 538-5051  FAX: (858) 538-5051
San Diego, California        -- Public Internet access / Mailing Lists
--------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing). Received on Wed Aug 07 2002 - 13:34:44 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US