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

Home -> Community -> Mailing Lists -> Oracle-L -> SQL struggle

SQL struggle

From: Saira Somani <saira_somani_at_yahoo.com>
Date: Tue, 25 Feb 2003 09:58:59 -0800
Message-ID: <F001.00558D7D.20030225095859@fatcity.com>


List Gurus,

I need help and I won't be ashamed to ask :)

Oracle 8.1.7 on AIX 4.3

Here is what my data looks like in a table called item_w:

WHSE_CODE    ITEM_NUM                       LAST_COST
------------ ------------------------------ ----------
HL1          111230                               1.12
CPD-TWH      111230-OR                               0
CPD-TGH      111230-OR                               0
HL1          50034                                 .91
MSH-CDS      50034                                   0
CPD-TGH      50034-OR                                0
HL1          650300                              4.789
TWH-STAT     650300                                  0
CPD-TWH      650300-OR                               0
CPD-TGH      650300-OR                               0

If you'll notice, only the items with WHSE_CODE='HL1' have a cost associated with them.

What I need to is:

Parse ITEM_NUM for those items which have a suffix of -OR in order to compare with an ITEM_NUM without -OR so that I can take the last cost from there and display it beside the one that has -OR. Also note, there are some $0 cost items that don't have a suffix of -OR; I would need to match those up with a cost as well.

So in the end, I suppose, this is the result I'm looking for:

WHSE_CODE    ITEM_NUM      LAST_COST	LAST_COST_REV
------------ ------------- -------------	-------------
HL1          111230        		1.12		   1.12
CPD-TWH      111230-OR			0		   1.12
CPD-TGH      111230-OR			0		   1.12
HL1          50034			0.91		   0.91
MSH-CDS      50034			0		   0.91
CPD-TGH      50034-OR			0		   0.91
HL1          650300			4.789		   4.789
TWH-STAT     650300			0		   4.789
CPD-TWH      650300-OR			0		   4.789
CPD-TGH      650300-OR 			0		   4.789	

And if any of you out there use Cognos Impromptu, perhaps you could tell me how I can achieve these results in a report.

Thanks in advance for your time,

Saira Somani
IT Support/Analyst
Hospital Logistics Inc.

--

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

Author: Saira Somani
  INET: saira_somani_at_yahoo.com

Fat City Network Services    -- 858-538-5051 http://www.fatcity.com
San Diego, California        -- Mailing list and web hosting services
---------------------------------------------------------------------
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 Tue Feb 25 2003 - 11:58:59 CST

Original text of this message

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