Run a query that will determine the number of parts to produce

I have the task that I have to determine the number of parts that need to be produced based on the number of products sold for the day (each product consists of many parts).
I am using SQL 11g Express.
I have stared at this for so long and tried so many different ways. Below are a few of what I have tried, with the error messages. I'm not sure where I'm going wrong to get this calculation. Any help here is greatly appreciated!
Here's my info:
/**PRODUCT**/
CREATE table Product
    SKU       VARCHAR2(10) NOT NULL,
    ProdDesc   VARCHAR2(50) NOT NULL,
    Price      NUMBER(5,2),
    PRIMARY KEY(SKU)
/**PART**/
CREATE table Part
    PartID     NUMBER(6) NOT NULL,
    PartDesc   VARCHAR2(50) NOT NULL,
    PRIMARY KEY(PartID)
/**PRODUCTPART**/
CREATE table ProductPart
    SKU        VARCHAR2(10) NOT NULL CONSTRAINT fk_ProductPart_Product REFERENCES Product (SKU),
    PartID     NUMBER(6) NOT NULL CONSTRAINT fk_ProductPart_Part REFERENCES Part (PartID),
    NumOfParts NUMBER(3),
    CONSTRAINT pk_ProductPart PRIMARY KEY (SKU, PartID)
CREATE table Customer
    CustID     NUMBER(6) NOT NULL,
    CustFname  VARCHAR2(20) NOT NULL,
    CustLname  VARCHAR2(20) NOT NULL,
    Company    VARCHAR2(40),
    Address    VARCHAR2(40) NOT NULL,
    City       VARCHAR2(30)NOT NULL,
    State      VARCHAR2(2)NOT NULL,
    Zip        NUMBER(5)NOT NULL,
    Phone      NUMBER(10)NOT NULL,
    PRIMARY KEY (CustID)
CREATE table CustOrder
    OrderID    NUMBER(6) NOT NULL,
    Qty        NUMBER(3) NOT NULL,
    OrderDate  Date NOT NULL,
    SKU        VARCHAR(10) NOT NULL CONSTRAINT fk_CustOrder_Product REFERENCES Product (SKU),
    CustID     Number(6) NOT NULL CONSTRAINT fk_CustOrder_Customer REFERENCES Customer (CustID),
    PRIMARY KEY (OrderID)
Here are some of the queries:
SELECT ProductPart.Qty
SELECT CustOrder.SKU,
sum(CustOrder.qty)
FROM CustOrder
    GROUP BY CustOrder.SKU;)
FROM ProductPart
WHERE ProductPart.Qty * sum(CustOrder.Qty)
ORA-00936: missing expression
SELECT o.OrderDate AS "Date Ordered",
       o.OrderDate + 5 AS "Date Due",
       pp.PartID AS "Part No.",
    pp.NumOfParts * COUNT(o.SKU) AS "Qty"
FROM CustOrder o
JOIN ProductPart pp
  ON o.SKU = pp.SKU
    GROUP BY pp.PartID, o.OrderDate, COUNT(o.SKU)
ORDER BY o.OrderDate
ORA-00934: group function is not allowed here
SELECT ProductPart.Qty,
       ProductPart.PartID,
       ProductPart.PartDesc
(SELECT COUNT(CustOrder.SKU)
FROM CustOrder
GROUP BY CustomerOrder.SKU)TotalProducts,
ProductPart.Qty * TotalProducts AS "Qty"
FROM ProductParty
WHERE CustOrder.SKU = Product.SKU
AND Product.SKU = ProductPart.SKU
ORA-00936: missing expression
SELECT ProductPart.Qty,
       ProductPart.PartID,
       ProductPart.PartDesc
(SELECT sum(CustOrder.qty)
FROM CustOrder
GROUP BY CustOrder.SKU)TotalProducts
    ProductPart.Qty * TotalProducts
    FROM ProductPart
ORA-00936: missing expression

Hi,
893443 wrote:
... CREATE table CustOrder
OrderID NUMBER(6) NOT NULL,
Qty NUMBER(3) NOT NULL,
OrderDate Date NOT NULL,
SKU VARCHAR(10) NOT NULL CONSTRAINT fk_CustOrder_Product REFERENCES Product (SKU),
CustID Number(6) NOT NULL CONSTRAINT fk_CustOrder_Customer REFERENCES Customer (CustID),
PRIMARY KEY (OrderID)
INSERT INTO CustOrder(OrderID, Qty, OrderDate, SKU, CustID)
VALUES(2101, 2, '10-26-2011', 'DVCK1212', 1101);You're still trying to put a VARCHAR2 into a DATE column. Depending on your NLS settings, that may work on your system (at least today), but it definiely doesn't work on mine.
Don't use a VARCHAR2 where a DATE is expected. Use TO_DATE to convert a string into a DATE:
http://download.oracle.com/docs/cd/E11882_01/server.112/e26088/functions203.htm#sthref1662
Ideally The report would look something like this:Why not like this?
ORDERDATE      PARTID PARTDESC                        TOTAL_QTY
10-24-2011       1003 12" X 24" Ventilated Shelf             42
10-24-2011       2001 12" X 12" Solid Shelf                 108
10-24-2011       3001 12" X 96" Side Panel                   50
10-25-2011       1004 12" X 30" Ventilated Shelf             72
10-25-2011       2001 12" X 12" Solid Shelf                  54
10-25-2011       2002 12" X 18" Solid Shelf                   6
10-25-2011       3001 12" X 96" Side Panel                   44
10-26-2011       1001 12" X 12" Ventilated Shelf             42
10-26-2011       1004 12" X 30" Ventilated Shelf              6
10-26-2011       2003 12" X 24" Solid Shelf                  12
10-26-2011       3001 12" X 96" Side Panel                   20Did you make some mistakes in your results? If not, explain how to get the correct results in the places where the ouput above is wrong. For example, how do you get the row for orderdate of Oct 26 and partid=2001?
{OrderDate    PartID    PartDesc NumOfParts(Total for that day)
10-24-2011    2001    12" X 12" Solid Shelf 108
10-24-2011    2003    12" X 24" Solid Shelf 32
10-24-2011    3001    96" Side Panel 50
10-25-2011    2002    12" X 18" Solid Shelf 6
10-25-2011    2001    12" X 12" Solid Shelf 54
10-25-2011    1004    12" X 30" Ventilated Shelf 72
10-25-2011    3001    96" Side Panel 44
10-26-2011    2001    12" X 12" Solid Shelf 12
10-26-2011    2004    12" X 30" Solid Shelf 6
10-26-2011    2003    12" X 24" Solid Shelf 12
10-26-2011    1001    12" X 12" Ventilated Shelf 30
10-26-2011    3011    96" Side Panel 20}Use \ tags, as described in my last message, before and after formatted text, to preserve spacing.
My issue is, I can't get the equation right to produce the total number of parts. I think I need to multiply ProductPart.NumOfParts by SUM(CustOrder.Qty) Group by CustOrder.SKU.More likely that you need to multiply numofparts * qty, and then take the SUM of the result.
Why would you GROUP BY sku?  Does each row of output represent a different product (and therefore a different sku), or does each row of output represent a different part. regardless of which product(s) that part is related to?
If you want a separate total for each orderdate, you'll have to include orderdate in the GROUP BY clause, too.
To get partdesc in the output, you'll either need to include partdesc in the GROUP BY clause, or wrap it in an aggregate fucntion.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

Similar Messages

  • OTL I am trying to wright a SQL query that will return the date the timesheet was submitted and date/time it was approved, can anyone guide me on this?

    Hi
    I am trying to wright a SQL query that will return the date the timesheet was submitted and date/time it was approved, can anyone guide me on this?
    I basically need person name who submitted, date - time it was submitted for approval, then the person who approved it and the date - time that it was approved
    Thanks
    Ruby

    Ruby,
    you can start with HXC_TIMECARD_SUMMARY table for submitter detail. But for approver details, i think you need WF tables to get the data for item type HXCEMP.

  • Is it posible a query that builds dynamically the number of columns?

    Hi experts!
    I have a query that shows amounts in 12 columns corresponding on the calendar months of the year.   Now,  I need to change that getting in a previous screen how many months the user wants to see.   The query has to build dynamically the number of columns to show.    Can I do that with query designer?  How?
    I am working in V7.0.
    I appreciate your help.
    Thanks!
    Ada.

    Hi experts!
    I have a query that shows amounts in 12 columns corresponding on the calendar months of the year.   Now,  I need to change that getting in a previous screen how many months the user wants to see.   The query has to build dynamically the number of columns to show.    Can I do that with query designer?  How?
    I am working in V7.0.
    I appreciate your help.
    Thanks!
    Ada.

  • Does anyone know of a VI or how to go about writing one that will prevent the computers time/date from being disabled while an application is running.

    Does anyone know of a VI or how to go about writing one that will prevent the computers clock/time from being disabled while an application is running. The time and date can normally be reset while an application is running by clicking on the time/date in the lower right-hand corner of the computer screen. I have an application that runs over several days and it is critical that the time and date of the computer not be changed. Is there an easy way to lock this out from the user? Note that I am what I consider an advanced beginner in LV.
    Thank you,
    Chuck
    Solved!
    Go to Solution.

    That is not something you can do from LabVIEW, as it is an operating system operation, and it will depend on the operating system that you're using. On Windows you can use a group policy to control this. Please Google on "prevent time and date change in windows".
    Also, please try to refrain from stuffing your entire message in the subject block. Keep the subject short, but descriptive enough so it can be understood what you are basically asking. Thanks.

  • How to determine the number of messages in a queue, that ...

    Hi,
    what's the proper way to count the number of the messages in an Advanced Queue that are currently visible to consumers?
    Currently we use:
    select count(*) from aq$queue_tab_name q where q.QUEUE = 'Q_NAME';
    The problem with that approach:
    If one consumer dequeues a lot of messages in one transaction, that change in the number of messages visible to other consumers is only made visible after the consumer issues a commit. Before the commit is issued, the above "select count(*) ..." statement (issued from a different DB-session) does not reflect the fact that one consumer consumed a lot of messages, messages that are not available to other consumers anymore (only exception: the original consumer issues a rollback sooner or later).
    So before the commit is issued:
    -the consumed messages are NOT visible to other consumers anymore (which is intended behaviour)
    -but the "select count(*) ..." statement (issued from a different DB session) does NOT reflect that fact
    So the case could arise that the queue becomes empty, while "select count(*) ..." says that e.g. 1000 messages are still in the queue.
    Is there a solution to this problem?
    PS: For our use-case we need these dequeue option :
    dbms_aq.remove;
    dbms_aq.first_message;
    dbms_aq.on_commit;
    Again, the queue itself works correctly, I just need to find a way to determine the number messages that are currently dequeable / visible to the consumers at specific point in time.
    I couldn't find a func/proc in dbms_aq for that purpose.
    Best wishes
    Peter

    The following might be of interest in better understanding the issue you are facing in a broader context:
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:5771117722373

  • [svn:fx-trunk] 5295: -add property file that will have the TLF build number in it

    Revision: 5295
    Author: [email protected]
    Date: 2009-03-13 08:50:57 -0700 (Fri, 13 Mar 2009)
    Log Message:
    -add property file that will have the TLF build number in it
    Added Paths:
    flex/sdk/trunk/in/tlf/tlf.properties

    Thats good news.

  • How can I determine the number and resolution of the current displays/screens?

    I am developing a vision application that will require a specific window size, thus the application must run with the screen resolution at predified levels. It is also possible that the application will run on a system with multiple monitors, so I need to be able to determine the number of monitors, and the resolution of each.

    Hi
    I recommend you to work with the VI Server functions (Application class properties). See my little example.
    Regards,
    Luca
    Attachments:
    VI_Server.vi ‏22 KB

  • How to determine the number of pixels of a desired object within a digital photograph?

    Hi everyone. I want to determine the number of pixels in an object that is part of a digital photo. I use cameras to film chunks of ice breaking away from ice cliffs or tidewater glaciers. I want to know the size of the ice chunk that my digital photographs capture. I know the width and height of the ice cliff in metres already, so I was thinking that I could convert the equivalent of 1 pixel : ? metres - this is really what I want to do. That way every time I see a chunk of ice breaking off, I can pull up the photo, outline the chunk, calculate how many pixels fill the area of ice removed by the chunk breaking off and convert to metres area 2 - thus giving me my size order. If anyone has ideas on how to do this I would really appreciate it, thanks so much community. I was thinking that Photoshop or Fireworks could help me with this, Ricky

    Thanks gener7 and normfb.
    The Photoshop help measurement page is brilliant and I think I can use the info on that page to work out my iceberg sizes. Check out the attached photo - you are looking at an ice cliff - essentially the front of a tidewater glacier that flows in the ocean. I'm a research student and I look at the process of iceberg calving - this is the term we use to define the sudden breaking away or detachment of ice chunks from glaciers that end in the sea.
    I used the lasso tool to crop the area of ice lost as a single chunk of ice detached from the ice cliff. At the same time I had the histogram window open. The histogram showed me how many pixels were contained in the cropped area. What I need to do now is work out what 1 pixel is equivalent to in metres. Soon I will have a digital elevation model for the ice cliff that will offer centimetre to metre scale resolution of the surface topography - so that should really help. The photographs I have are taken every 30 seconds - which is brilliant for documenting how the geometry of the ice cliff adjusts in response to detaching ice pieces and also because the ice is moving. I am a research student in Canada, and at the time I took the photos we measured that the ice cliff was advancing at a rate of approximately 12 metres per day! That's pretty fast. The flow of the ice is a first order control on the rate of iceberg production - you are essentially pushing ice into the ocean where it breaks off. I'm having to learn everything Photoshop from scratch...so please bare with me because maybe some of the photoshop questions I ask are simple to most!
    I noticed the "integrated density" function on the help sheet you suggested. This function also provides the square number of pixels contained in the cropped area I select...I guess this is similar to the histogram right?
    Either way - i just need the scale conversion to go from 1 pixel : metres or cm equivalent. At that point I think I will have to manually select every single iceberg event from my time-lapse photos and do this the manual way!  I have about 800 events to manually digitise and calculate the area for...
    Thanks everyone, Ricky

  • How to change a hi res picture of fingers in a way that will make the fingerprints clear ?

    Hi, I need to transform hi resolution pictures of fingers in a way that will cause the fingerprints to stand out.
    The purpose of this is so I may count the number of ridges and furrows of each fingerprint.
    Many thank !!
    Eran

    Before removing a blade always run a decommision, even if you are going to use the same service profile:
    Server - General - Server Maintenance.
    When you insert it in another slot, it will run a re-acknowldge. If you are going to apply the same service profile with the local disk configuration that you mention, the data should stay there.
    If the Protect Configuration box is checked, the server retains the configuration  in the local disk configuration policy even if the server is  disassociated from the service profile.
    When a service profile is disassociated from a server and a new  service profile associated, the setting for the Protect Configuration  property  in the new service profile takes precedence and overwrites the  setting in the previous service profile.
    Note   
    If you disassociate the server from a service  profile with this option enabled and then associate it with a new  service profile that includes a local disk configuration policy with  different properties, the server returns a configuration mismatch error  and the association fails.

  • Aperture import plug-in won't run.  After examining my library the number of image files stays at "undetermined" and the import button stays greyed out.  Any thoughts?

    Aperture import plug-in won't run.  After examining my library the number of image files stays at "undetermined" and the import button stays greyed out.  Any thoughts?

    Others have the same issue, with the import button being grayed out.  My trail copy expired, but I believe by poking around in the options and selecting another Aperture library and re-selecting, I was able to continue.
    The problem is common enough, that hopefully Adobe will address.  In the mean time, try repairing your Aperture library, checking permissions, exporting a subset of your library for a test, or try putting that library subset on an external drive.  (Can usually avoid permissions issues.)

  • Unable to determine the number of SMSs generated by the message

    In JES5, I tested the SMS logging with two options; standard and xml.
    In both cases, I was unable to determine the number of SMSs generated by the message.
    However, such information can be found in the debug log;
    If i enable the debug logging, the desired information is available:
    10:15:41.59: 2-fragment(2250): The message will be sent as 4 SMS messages
    Nevertheless, Debug logging cannot be enabled all the time since it is pretty verbose.
    It was said that XML based logging released in JES5 will include the number of messages in the mail.log_current.
    But i dont find such information in it.
    Would anyone please tell me if this is applicable?
    what parameters should be changed or modified in order to make such
    information appear in the mail.log file?
    Thanks!

    I've not examined the doc, but I suspect that at least one of the option logging settings will do that for you. Please do have a look at the "channel option files" and the logging levels.

  • Determine  the number of periods on 0FISCPER3

    I have a problem concerning the design of a query. The aim of the query is firstly to get rid of variable periodic variations of specific volume data and secondly to compare this data with the same number of periods of the previous year.
    Therefore I inserted the following columns and help columns:
    S1: key figure volume ; variables: business year (0FISCYEAR) ; periods (=FISCPER3; from - to)
    S2: key figure volume; variable offset  of  business year (-1)
    S3: formula: S2/12 (therefore mean value of the previous business year)
    S4: (formula variable to determine  the number of periods) S3 * number of periods  (formula variable)
    Actually the formula variable (attribute 0FISCPER3, substitute path, figure) picks up the variable 0FISCPER3 twice: the value from and to. A calculation of the difference within the formula variable did not work.
    Now it is not possible for Business Warehouse to carry out the replacement of the figure.
    <i>Message
    However, these are not the same for all formula components , or the selection is not available in the terms. Another possibility is that the variable cannot be consistently replaced by “from” or “to”</i>
    Can you tell me which mistake I made  respectively how to construct this query!
    Thank you very much in advance.

    Hi,
    the best is to go with a varexit.
    Assuming your var on 0FISCPER3 is name VPER3.
    Create a fromula variable not ready for input processed by user exit: VNPER.
    Here's the ABAP:
    DATA:
        l_poper_from LIKE T009C-POPER,
        l_poper_to LIKE T009C-POPER,   
        l_nper TYPE I.
      WHEN 'VNPER'.
        IF i_step = 2.
          LOOP AT i_t_var_range INTO loc_var_range WHERE vnam = 'VPER3'.
            CLEAR l_s_range.
            MOVE loc_var_range-low TO l_poper_from.
            MOVE loc_var_range-high TO l_poper_to.   
            l_nper = l_poper_to - l_poper_from + 1.   
            l_s_range-low      = l_nper.
            l_s_range-sign     = 'I'.
            l_s_range-opt      = 'EQ'.
            APPEND l_s_range TO e_t_range.
            EXIT.
          ENDLOOP.
        ENDIF.
    please note that the code may be adjusted.
    Use then your form varexit in your columns calculations.
    hope this helps...
    Olivier.
    Message was edited by:
            Olivier Cora

  • Determine the number of lines of textfield or floating field

    Hi,
    Is there a way to determine the number of lines of text in a textfield or in a floatingfield.
    My problem is that I'm creating a form with three tables(made of subforms) underneed each other that needs to be set to hidden when the total of rows is greater than 25.
    Now it would be easy to just count the rows but these rows can exist of multiple lines of text.
    The fields of my row are floating fields so when the text is bigger than the displayable width the text continous on a new line in the same row. So I need to know when this happens because now I can show only 24 rows.
    I tried counting the characters but this doesn't work, when there are a lot of 'i,j,l' or other small characters I can place 40 characters in my textfield, but when there are a lot of 'm,w' characters I can place only 22 characters in my field.
    I also tried to use xfa.layout.h(TextField1,"cm") to determine the height of the field, but it always retuns the value -1. I get the same -1 with the y or x - position.
    Does anybody have an idea how to solve this problem?
    Thanks in advance,
    RonnyR

    oops ... i got it thanks.
    code below -----
    for(var i=0; i <= s.length-1; i++)
    sCurrentLetter = s.substring(i,i+1);
    if (s.charCodeAt(i) == 13)
    // this is a line break

  • Having stopped audio with a swf inside a sidelet can someone create a swf that will resume the audio

    Ok, rick is going to post the fla of this file and I will
    post the swf. Basically this is all about having a slide that has
    audio running all the way through and enabling the user to roll
    over a sidelet and have the video and audio stop playback.
    At present, the max you can achieve is, to stop video. The
    audio keeps going and of course everything gets out of
    sync. Rick has create a swf that you input into a sidelet (
    after having imported your image or video ) which stops the audio.
    Fantasitc. Unfortunatly he was not successful in creating a swf
    that will resume the audio.
    So there is the mission. To create something that will resume
    the audio, be it a swf inside the sidelet or something else.

    Hi there paul. Am I right in thinking that your code will
    mute the audio. In my situation this would cause problems becasue
    you would roll over the sidelet - the audio would go silent and
    when you rolled off, or resumed the audio, it would have been
    playing so again the video and audio will be out of sync.
    Rick - rather than another swf which would activate the audio
    and video when you roll off the sidelet ( while that is the perfect
    solution ) what about looking at a button the user can press to
    resume things, maybe Im wrong but that sounds a little easier.
    ( however for all those reading this that is not really the
    solution I am looking for, what Im looking for is the above
    solution where you can just roll off and on and so on )

  • How do I determine the number of plots on a waveform graph?

    How do I determine the number of plots that have previously been plotted on a waveform graph? I am loading dynamic data from a file. If I convert to an array and size it and there is only one plot, I get the number of data points and I don't know how to tell the difference.

    Usually by reading the graph terminal or a local of it and determining the first or second dimension (not sure which at the moment) size of the resulting 2 dimensional array. If it is a 1 dimensional array you have either only one plot or an array of clusters each representing one plot. But as these data types are determined by compile time, there shouldn't be a problem with this causing ambiguity.
    Rolf K
    Rolf Kalbermatter
    CIT Engineering Netherlands
    a division of Test & Measurement Solutions

Maybe you are looking for

  • Insert into Microsoft access 2010 Database on sharepoint using OLEDB

    Hi, want to insert data into a microsoft access web db using oledb object. but the i am unable to open the database.     dbLoc = "http://XXXX.com/project/design/Test_Web_DB     Dim strConnection As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Sou

  • POST - RESTful Service to insert a row

    Hello, How can We utilize Post method in APEX RESTful ? I would like to insert a row (contact details) into the database from a form on a STATIC / Standalone HTML page. I found this example, but I have no idea how to accomplish my objective ? http://

  • Problem about tdp for sap rman error

    I installed tdp for sap and scheduled a online backup , after the backup finished, I checked the log. all data files were backuped successfully. but there is an error about rman. I do not know how to do about that? Could you help me? I think the back

  • Can jdk1.6 be installed in win 98 o.s

    i developed a code in jdk1.6, while running that code in a system consisting of win 98 as o.s and jdk1.3 it is showing an error message as follows..... Errors while compiling : E:\Project>javac Home.java Home.java:22: cannot access Login bad class fi

  • Erase hard drive on a dead mac

    Is there any way to erase a hard drive on a dead mac? When I press the power button, the start up sound goes halfway, the screen remains black but the LED turns on. I was told at the Apple store there's water damage so I'd like to sell it for parts b