From oracle-l-bounce@freelists.org Tue Mar 2 10:09:05 2004 Return-Path: Received: from air189.startdedicated.com (root@localhost) by orafaq.com (8.11.6/8.11.6) with ESMTP id i22G95v30103 for ; Tue, 2 Mar 2004 10:09:05 -0600 X-ClientAddr: 206.53.239.180 Received: from turing.freelists.org (freelists-180.iquest.net [206.53.239.180]) by air189.startdedicated.com (8.11.6/8.11.6) with ESMTP id i22G94o30092 for ; Tue, 2 Mar 2004 10:09:05 -0600 Received: from turing (localhost [127.0.0.1]) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id 32511395C04; Tue, 2 Mar 2004 11:07:52 -0500 (EST) Received: with ECARTIS (v1.0.0; list oracle-l); Tue, 02 Mar 2004 11:06:31 -0500 (EST) X-Original-To: oracle-l@freelists.org Delivered-To: oracle-l@freelists.org Received: from smtp106.mail.sc5.yahoo.com (smtp106.mail.sc5.yahoo.com [66.163.169.226]) by turing.freelists.org (Avenir Technologies Mail Multiplex) with SMTP id 22045395C21 for ; Tue, 2 Mar 2004 11:06:28 -0500 (EST) Received: from unknown (HELO itlap01) (saira?somani@207.139.2.138 with login) by smtp106.mail.sc5.yahoo.com with SMTP; 2 Mar 2004 15:54:05 -0000 From: "Saira Somani-Mendelin" To: Subject: Mean SQL statement! Date: Tue, 2 Mar 2004 10:56:54 -0500 Organization: Hospital Logistics Inc. Message-ID: <007401c4006e$fde01460$e20110ac@itlap01> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook, Build 10.0.2627 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4807.1700 Importance: Normal X-archive-position: 25 X-ecartis-version: Ecartis v1.0.0 Sender: oracle-l-bounce@freelists.org Errors-To: oracle-l-bounce@freelists.org X-original-sender: saira_somani@yahoo.com Precedence: normal Reply-To: oracle-l@freelists.org X-list: oracle-l I need help :) I have to write a SELECT statement which addresses the following problem (because I eventually have to turn this into a view which can be accessed through the application's presentation layer): Each item does not necessarily have a PRICE record associated with it. In the case where it doesn't have a PRICE record, it has to get the $$$ from another table called ITEM_W. How do I get this into the following SELECT statement? Not only that! I then have to use this $$$ value and calculate a unit $$$ using a multiplier from another table, and then do some other calculation using the unit $$$ and another multiplier and another number to get an extended $$$ value. Here's the statement as it is: SELECT D.CUST_NUM, F.CUST_GROUP, D.SHIP_NUM, A.ITEM_NUM, (SELECT Z.REQUEST_ITEM FROM ITEM_C Z WHERE D.CUST_NUM = Z.CUST_NUM AND D.ITEM_NUM = Z.ITEM_NUM) AS REQUESTED_ITEM, A.REPORT_ITEM_NUM, D.SELL_UOM, C.UOM, C.MULTIPLIER AS SELL_UOM_MULT, (SELECT Z.PRICE_1 FROM PRICE Z WHERE A.REPORT_ITEM_NUM = Z.ITEM_NUM AND F.CUST_GROUP = Z.CUST_GROUP AND E.CUST_NUM = F.CUST_NUM) AS PRICE FROM ITEM A, ITEM_SELL_UOM B, UOM C, CUST_SHP_ITEM D, CUST_SHP E, CUSTOMER F WHERE A.ITEM_NUM = B.ITEM_NUM AND B.UOM_ID = C.UOM_ID AND A.ITEM_NUM = D.ITEM_NUM AND D.SELL_UOM = C.UOM AND D.SHIP_NUM = E.SHIP_NUM AND D.CUST_NUM = E.CUST_NUM AND E.CUST_NUM = F.CUST_NUM AND E.CUST_NUM = '33' AND E.SHIP_NUM = '14' And here is some of the output: CUST_NUM CUST_GROUP SHIP_NUM ITEM_NUM REQUESTED_ITEM REPORT_ITEM_NUM SELL_UOM UOM SELL_UOM_MULT PRICE 33 SWHS 14 114012 66600 114012 EA EA 1 51.49 33 SWHS 14 114013 66610 114013 EA EA 1 45.55 33 SWHS 14 114017 66620 114017 EA EA 1 120.93 33 SWHS 14 12720 12720 12720 EA EA 1 33 SWHS 14 63510 63510 63510 EA EA 1 33 SWHS 14 115910 66980 115910 EA EA 0.02 57.94 33 SWHS 14 21901 66990 21901 PK50 PK50 1 62.09 Thanks in advance!!! Saira ---------------------------------------------------------------- Please see the official ORACLE-L FAQ: http://www.orafaq.com ---------------------------------------------------------------- To unsubscribe send email to: oracle-l-request@freelists.org put 'unsubscribe' in the subject line. -- Archives are at http://www.freelists.org/archives/oracle-l/ FAQ is at http://www.freelists.org/help/fom-serve/cache/1.html -----------------------------------------------------------------