help with quierying, a table with varchar as dates

the guys need a little help im close, but I can't just close the deal.
I have a table that the field is dataytped as varchar2, but she holds a date as such date of today '20100615'.
I know that the first thing that you guys are going to say is that this must be formatted as a date but it is not my table and I do deal with this.
Here's how the problem im trying to query for a range of dates, and im having a hell of a time to do.
as you cannot say my query below im trying to bring back only 15 days worth of data by date.
can someone please point out what is obvious. I was home for a day now to try to get this working.



SELECT DISTINCT to_date (fwvitals_date, 'YYYYMMDD') "fwvitals_date".
OF fwvitals
where fwvitals_date
between (((SELECT MAX (fwvitals_date) OF FWVITALS)))
Double ((SÉLECTIONNEZ to_CHAR (sysdate-15, «AAAAMMJJ»)))

Hello

user633029 wrote:
the guys need a little help im close, but I can't just close the deal.
I have a table that the field is dataytped as varchar2, but she holds a date as such date of today '20100615'.
I know that the first thing that you guys are going to say is that this must be formatted as a date but it is not my table and I do deal with this.

You are absolutely right!

Here's how the problem im trying to query for a range of dates, and im having a hell of a time to do.
as you cannot say my query below im trying to bring back only 15 days worth of data by date.
can someone please point out what is obvious. I was home for a day now to try to get this working.

SELECT DISTINCT to_date (fwvitals_date, 'YYYYMMDD') "fwvitals_date".
OF fwvitals
where fwvitals_date
between (((SELECT MAX (fwvitals_date) OF FWVITALS)))
Double ((SÉLECTIONNEZ to_CHAR (sysdate-15, «AAAAMMJJ»)))

"WHERE x BETWEEN y AND z" is equivalent to
"WHERE x > = y AND x.<=>
If y > z, no line will never be allowed, and if there is the great artist of value in your table, then lines (probably) very little, perhaps only 1 will satisfy the same if condition z > y.

What exactly are you trying to do?
It helps if post you a small example of data (CREATE TABLE and INSERT statements) and the results desired from these data. If the results are conditional, give some examples, for example, "if I run the query at any time on 15 June, I want to... but if it's June 16, so I want to..." »

If you want the most recent 15 days, including today (that is, when run on 15 June, you want from 1 June until 15 June) then:

SELECT DISTINCT
     fwvitals_date
FROM      fwvitals
WHERE       fwvitals_date     BETWEEN     TO_CHAR (SYSDATE - 14, 'YYYYMMDD')
               AND     TO_CHAR (SYSDATE,      'YYYYMMDD')
;

Fortunately, the strings are in a format such as sorting is explicit, so you don't have to run TO_DATE on each of them and get conversion errors.

Published by: Frank Kulash, June 15, 2010 21:52

Tags: Database

Similar Questions

  • * Need help with importing partial data of RDBMS table NHI repository *.

    Hello

    I need help to import the partial table RDBMS data, I tried the content in the logical source but still show me all the data available in the database.

    The table contains the partitioned data for which I want to only import single partion according to the partion of function value.

    IE contry = 'Fr '.

    Thanks in advance.

    See you soon,.
    Rajeev

    One possibility is to do the filtering on the physical level itself. You could use a physical table of type 'Select' and filter the data.

    Thank you!

  • Help with downloading blob data type

    Can Hi all, someone please help me with the download of blob data types. I created the following table, as well as triggers and seq. However, when I try to run the program I get the following error.

    "Error (2.5): PLS 00049: bad connection variable ' NEW. '. ' ID'.

    Create table proc_doc (
    pd_id number,
    pd_doc blob);
    
    
    CREATE SEQUENCE proc_doc_seq;
    CREATE or replace TRIGGER proc_doc_trig BEFORE INSERT ON proc_doc FOR EACH ROW
    BEGIN
        :NEW.id := proc_doc_seq.NEXTVAL;
    END;
    /
    
    
    
    

    Images will usually be on the client. If the customer needs to read binary image data and argue that the database for storage.

    Like Mike suggested, the customer can be a web browser, do a upload of file from the database. This example uses Apache and MOD_PLSQL in the web layer. See understanding mod_plsql for more information on creating a loading table in the database, and how the HTML form should look similar to the web client to submit a file upload.

    Oracle Apex simplifies it for you.

    Another method is to use DBMS_LOB - client creates a BLOB in the database, bed a piece of the image file, and then write add this piece to the BLOB.

    The customer can also support LOBs via a local client interface or o - o class. This generally allows to create a bind variable LOB and argue that the database.

    And no, you cannot use SQL * more as a client to download files. If the command line is preference, use SQL * Loader to load and submit the files of the database.

  • Need help with RANK() on data ZERO

    Hi all

    I am using Oracle 10 g and running a query with RANK(), but it is not a desired output. Pleas HELP!

    I have a STATUS table, which shows the history of the State of the command... I have a requirement to indicate the order and the last date of State (max). If there is no date NULL for a command can show NULL.

    STATUS
    ------------
    ORD_NO | STAT | DT
    ---------------------------------------------
    1. Open |
    1. Pending |
    2. Open |
    2. Pending |
    3. Open | 01/01/2009
    3. Pending | 06/01/2009
    3. Close |
    4. Open | 02/03/2009
    4. Close | 04/03/2009
    Result should be (max date for each ORD_NO NULL otherwise):
    ORD_NO | DT
    ---------------------------------------------
    1.
    2.
    3.
    4. 04/03/2009
    ----------------------------------------------
    CREATE THE TABLE Status (NUMBER of ORD_NO, STAT VARCHAR2 (10), DT DATE);
    INSERT INTO the status of the VALUES (1, 'Open', NULL);
    INSERT INTO the status of VALUES (1, 'Waiting', NULL);
    INSERT INTO the status of VALUES (2, 'Open', NULL);
    INSERT INTO the status of VALUES (2, 'Waiting', NULL);
    INSERT INTO the status of VALUES (3, 'open', 1 JAN 2009');
    INSERT INTO the status of VALUES (3, 'pending', 6 JAN 2009');
    INSERT INTO status VALUES (3, 'Close', NULL);
    INSERT INTO the status of VALUES (4, 'open', 2 MAR 2009');
    INSERT INTO status VALUES (4, 'Close', 4 MAR 2009');
    COMMIT;

    I tried using the RANK function to rank all orders by date. So accustomed ORDER BY cluse to date down the order dates thinking null would be on top and is grouped by each ORD_NO.

    SELECT ORD_NO, DT, RANK() OVER (ORDER BY DT DESC ORD_NO PARTITION)
    STATUS;

    .. but the result was something...
    ORD_NO | DT | RANKING
    ---------------------------------------------
    *1 | | 1 *.
    *1 | | 1 *.
    *2 | | 1 *.
    *2 | | 1 3 | 1
    3. 06/01/2009 | 2
    3. 01/01/2009 | 3
    4. 2009-03-04 | 1
    4. 02/03/2009 | 2
    ----------------------------------------------

    I don't know why, is not the first two ORD_NOs has no group and why the ranking of 1 assigned to them. I'm assuming something like:
    ORD_NO | DT | RANKING
    ---------------------------------------------
    *1 | | 1 *.
    *1 | | 0 h
    *2 | | 1 *.
    *2 | | 1 *.
    3 | | 1
    3. 06/01/2009 | 2
    3. 01/01/2009 | 3
    4. 2009-03-04 | 1
    4. 02/03/2009 | 2
    ----------------------------------------------

    Please guide me if I am missing something here?

    Concerning
    Sri

    Hello

    I think the last stat for 1 and 2 is ongoing unopened.

    Salim cordially.

    SQL> SELECT   ord_no, MAX (stat)KEEP (DENSE_RANK LAST ORDER BY dt) stat,
      2           MAX (dt)KEEP (DENSE_RANK LAST ORDER BY dt) dt
      3      FROM status
      4  GROUP BY ord_no;
    
        ORD_NO STAT       DT
    ---------- ---------- ----------
             1 Pending
             2 Pending
             3 Close
             4 Close      2009-03-04
    
    SQL> 
    

    Published by: Salim champion 2009-05-05 13:09

  • helps with reading the data

    I got the measurement and automation studio let me the VI attached to read in some readings of strain gage, but I get those huge files with headers that break everything that makes it a real pain to process data outside of labview. Can someone help me

    (1) get the files to write with one header

    (2) sample the signal at a lower rate, so I do not have 16 meg files or anything whenever I do a data collection

    I would really appreciate it.

    Thank you
    Brian

    There is another connection on the lower part of the writing of the file function where you can connect to a wrong to say, do not write the header.

    Activate context-sensitive help (Ctrl-H), then select the feature to see.

  • help with LAG () AND dates

    I have at this moment the following query
      SELECT "DATE",
              "CELL_SITE",
              "LASTV_ATTCNT",
              "LASTV_ATTCNT2",
              "LASTV_BLKCNT",
              "LASTV_DRPCNT",
              "V_ATT_CNT",
              "V_CUST_BLK_CNT",
              "V_DRP_CALL_CNT",
              "LASTD_ATTCNT",
              "LASTD_BLKCNT",
              "LASTD_DRPCNT",
              "D_ATT_CNT",
              "D_CUST_BLK_CNT",
              "D_DRP_CALL_CNT"          
         FROM (  SELECT DATE,
                       CELL_SITE,
                        LAG (SUM (V_ATT_CNT), 24)
                           OVER (PARTITION BY BSM_NM ORDER BY DATE)
                           AS "LASTV_ATTCNT",
                        LAG (SUM (V_CUST_BLK_CNT), 24)
                           OVER (PARTITION BY BSM_NM ORDER BY DATE)
                           AS "LASTV_BLKCNT",
                        LAG (SUM (V_DRP_CALL_CNT), 24)
                           OVER (PARTITION BY BSM_NM ORDER BY DATE)
                           AS "LASTV_DRPCNT",
                        LAG (SUM (D_ATT_CNT), 24)
                           OVER (PARTITION BY BSM_NM ORDER BY DATE)
                           AS "LASTD_ATTCNT",
                        LAG (SUM (D_CUST_BLK_CNT), 24)
                           OVER (PARTITION BY BSM_NM ORDER BY DATE)
                           AS "LASTD_BLKCNT",
                        LAG (SUM (D_DRP_CALL_CNT), 24)
                           OVER (PARTITION BY BSM_NM ORDER BY DATE)
                           AS "LASTD_DRPCNT",
                        SUM (V_ATT_CNT) AS "V_ATT_CNT",
                        SUM (V_CUST_BLK_CNT) AS "V_CUST_BLK_CNT",
                        SUM (V_DRP_CALL_CNT) AS "V_DRP_CALL_CNT",
                        SUM (D_ATT_CNT) AS "D_ATT_CNT",
                        SUM (D_CUST_BLK_CNT) AS "D_CUST_BLK_CNT",
                        SUM (D_DRP_CALL_CNT) AS "D_DRP_CALL_CNT"
                   FROM DMSN.DS3R_FH_1XRTT_FA_LVL_KPI
                  WHERE DATE >
                             (SELECT MAX (DATE) FROM DMSN.DS3R_FH_1XRTT_FA_LVL_KPI)
                           - 2
               GROUP BY DATE, CELL_SITE)
        WHERE DATE >=
                 (SELECT MAX (DATE) - NUMTODSINTERVAL (12, 'HOUR')
                    FROM DMSN.DS3R_FH_1XRTT_FA_LVL_KPI)
    What I've noticed, is that the LAG function is kind of what I want but not exactly. Let's say that I have given for the hours of 12: 00, 01:00, 02:00, 03:00 04:00, 05:00, 06:00, 07:00, 08:00, 09:00, 10:00, 11:00, 12:00 and the time is 12:00, the LAG function goes back to 12 h, which is what he should do.

    but lets say that I have given for 12 h, 01:00, 02:00, 03:00 04:00, 05:00, 07:00, 08:00, 09:00, 10:00, 11:00, 12:00, but it me MISSING at 06:00 (no data from 06:00). The lag function now back at 23:00 instead of 12 AM because the time 06:00 is missing.

    If I have data for 12: 00 01:00, 02:00, 03:00 04:00, 07:00, 08:00, 09:00, 10:00, 11:00, 12:00 and am MISSING 05:00 and 06:00, the data will return to 22:00 then and not only from 12: 00.

    Can I prevent this and always just come back in 12 hours?

    Published by: k1ng87 on April 25, 2013 13:27

    Hello

    k1ng87 wrote:

    ...
    LAG (SUM (V_ATT_CNT), 24)
    OVER (PARTITION BY BSM_NM ORDER BY DATE)
    AS "LASTV_ATTCNT",
    LAG (SUM (V_CUST_BLK_CNT), 24)
    OVER (PARTITION BY BSM_NM ORDER BY DATE)
    AS "LASTV_BLKCNT",
    LAG (SUM (V_DRP_CALL_CNT), 24)
    OVER (PARTITION BY BSM_NM ORDER BY DATE)
    AS "LASTV_DRPCNT",
    ...
    

    Since you want to so many columns of the same previous row, it would be probably easier and more effective to make a self-join, rather than so many functions of SHIFT.

    What I've noticed, is that the LAG function is kind of what I want but not exactly. Let's say that I have given for the hours of 12: 00, 01:00, 02:00, 03:00 04:00, 05:00, 06:00, 07:00, 08:00, 09:00, 10:00, 11:00, 12:00 and the time is 12:00, the LAG function goes back to 12 h, which is what he should do.

    You always pass 24 as 2nd argument offset; What does "Return the value of the line 24 of the precding." If there is a line for each hour, the current line is from 12:00, then wouldn't 24 ranks back would be from 12:00 yesterday, not 12 AM? Maybe you wanted to spend 12, not 24, as the second argument of LAG. I'll assume you really want the 24 line rom now on, but the technique is the same that that number either 24 or 12.

    but lets say that I have given for 12 h, 01:00, 02:00, 03:00 04:00, 05:00, 07:00, 08:00, 09:00, 10:00, 11:00, 12:00, but it me MISSING at 06:00 (no data from 06:00). The lag function now back at 23:00 instead of 12 AM because the time 06:00 is missing.

    If I have data for 12: 00 01:00, 02:00, 03:00 04:00, 07:00, 08:00, 09:00, 10:00, 11:00, 12:00 and am MISSING 05:00 and 06:00, the data will return to 22:00 then and not only from 12: 00.

    Can I prevent this and always just come back in 12 hours?

    A self-join would handle this automatically: it will look for the corresponding line, without regard for other lines may be present or absent.

    If you really had to do with the analytical functions, you can use MIN or FIRST_VALUE with a window of the range:

    RANGE BETWEEN  1 + (.5 / 24)  PRECEDING
          AND      1 - (.5 / 24)  PRECEDING
    

    DATE when you ORDER BY a column (do not call ' DATE'), the units are 1 day, so 1 + (.5/24) days ago is 24.5 hours; in other words, the window includes only DATES between 24.5 and 23.5 hours.

    If, for some reason, you really want to call LAG, so you could do an outer join to ensure that a row had been present for each of the previous 24 hours.

    I hope that answers your question.
    If not, post a small example data (CREATE TABLE and only relevant columns, INSERT statements) and also publish outcomes from these data.
    Explain, using specific examples, how you get these results from these data.
    Always say what version of Oracle you are using (for example, 11.2.0.2.0).
    See the FAQ forum {message identifier: = 9360002}

  • Please help with error: outdated data (screenshots inside)

    Hello

    I'm new to OAF and I develop a data entry page, I get an error when I press Apply to submit the record of entry:

    Page:

    Untitled3.jpg

    Error:

    Untitled1.jpg

    Untitled4.jpg

    InsertCO.java:

    /*===========================================================================+
    |   Copyright (c) 2001, 2005 Oracle Corporation, Redwood Shores, CA, USA    |
    |                         All rights reserved.                              |
    +===========================================================================+
    |  HISTORY                                                                  |
    +===========================================================================*/
    package prajkumar.oracle.apps.fnd.insertdemo.webui;
    
    
    import oracle.apps.fnd.common.VersionInfo;
    import oracle.apps.fnd.framework.webui.OAControllerImpl;
    import oracle.apps.fnd.framework.webui.OAPageContext;
    import oracle.apps.fnd.framework.webui.beans.OAWebBean;
    import oracle.apps.fnd.framework.OAApplicationModule;
    import oracle.jbo.domain.Number;
    import oracle.apps.fnd.common.MessageToken;
    import oracle.apps.fnd.framework.OAException;
    import oracle.apps.fnd.framework.OAViewObject;
    import oracle.apps.fnd.framework.webui.OAWebBeanConstants;
    
    
    /**
    * Controller for ...
    */
    public class InsertCO extends OAControllerImpl
    {
      public static final String RCS_ID="$Header$";
      public static final boolean RCS_ID_RECORDED =
            VersionInfo.recordClassVersion(RCS_ID, "%packagename%");
    
    
      /**
       * Layout and page setup logic for a region.
       * @param pageContext the current OA page context
       * @param webBean the web bean corresponding to the region
       */
      public void processRequest(OAPageContext pageContext, OAWebBean webBean)
      {
        super.processRequest(pageContext, webBean);
        
            if (!pageContext.isFormSubmission())
            {
             OAApplicationModule am = pageContext.getApplicationModule(webBean);
             am.invokeMethod("createRecord", null);
            }
          
          }
    
    
    
      /**
       * Procedure to handle form submissions for form elements in
       * a region.
       * @param pageContext the current OA page context
       * @param webBean the web bean corresponding to the region
       */
      public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)
      {
          super.processFormRequest(pageContext, webBean);
           OAApplicationModule am = pageContext.getApplicationModule(webBean);
           // Pressing the "Apply" button means the transaction should be
           // validated and committed.
                      
           if (pageContext.getParameter("Apply") != null)
           {
            OAViewObject vo = (OAViewObject)am.findViewObject("InsertVO1");
            String JobNumber = (String)vo.getCurrentRow().getAttribute("JobNumber");
            String JobDescription = (String)vo.getCurrentRow().getAttribute("JobDescription");
                             
            am.invokeMethod("apply");
                             
            // Create a FND Message with name "TEST_CREATE_CONFIRM" with two
            // tokens                 
            MessageToken[] tokens = { new MessageToken("JOB_NUMBER",JobNumber),
                                      new MessageToken("JOB_DESCRIPTION",JobDescription)
                                    };
         
            OAException confirmMessage = new OAException( "FND",
                                           "TEST_CREATE_CONFIRM", tokens,
                                           OAException.CONFIRMATION, null);
           
              
            pageContext.putDialogMessage(confirmMessage);
            pageContext.forwardImmediately(
             "OA.jsp?page=/prajkumar/oracle/apps/fnd/insertdemo/webui/InsertPG",
              null, OAWebBeanConstants.KEEP_MENU_CONTEXT,
              null,
              null,
              true, // retain AM
              OAWebBeanConstants.ADD_BREAD_CRUMB_NO);
           }
      }
    
    
    }
    
    
    
    
    
    
    
    
    
    
    
    

    Untitled2.jpg

    InsertAMImpl.java:

    package prajkumar.oracle.apps.fnd.insertdemo.server;
    
    
    import oracle.apps.fnd.framework.server.OAApplicationModuleImpl;
    import oracle.apps.fnd.framework.server.OAViewObjectImpl;
    import oracle.apps.fnd.framework.OAViewObject;
    import oracle.jbo.Row;
    import oracle.jbo.Transaction;
    
    
    // ---------------------------------------------------------------------
    // ---    File generated by Oracle ADF Business Components Design Time.
    // ---    Custom code may be added to this class.
    // ---    Warning: Do not modify method signatures of generated methods.
    // ---------------------------------------------------------------------
    public class InsertAMImpl extends OAApplicationModuleImpl {
        /**This is the default constructor (do not remove)
         */
        public InsertAMImpl() {
      
        }
    
    
        /**Sample main for debugging Business Components code using the tester.
         */
        public static void main(String[] args) {
            launchTester("prajkumar.oracle.apps.fnd.insertdemo.server", /* package name */
          "InsertAMLocal" /* Configuration Name */);
        }
    
    
        /**Container's getter for InsertVO1
         */
        public OAViewObjectImpl getInsertVO1() {
            return (OAViewObjectImpl)findViewObject("InsertVO1");
        }
      
        public void createRecord()
        {
          OAViewObject vo = (OAViewObject)getInsertVO1();
       
          if (!vo.isPreparedForExecution())
          {
                vo.executeQuery();
          }
       
          Row row = vo.createRow();
          vo.insertRow(row);
          row.setNewRowState(Row.STATUS_INITIALIZED);
        }
      
        public void apply()
        {
          getTransaction().commit();
        }
    }
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    

    Please notify.

    Kind regards

    Joe

    I think that you referenced the AM several times on the Page that causes the error.

    See you soon

    AJ

  • Help with a code date of Expiration of JavaScript PDF

    I need to set an expiry date on a PDF document, but one I got turn up this guard to give me the command close even when the date is not just alert + doc

    -edit expiration date - start
    var lastDay = 26
    var lastMonth = 7
    lastYear var = 2010
    -end to change the expiration - date
    var sessione
    var today = new Date();
    var myDate = new Date();
    lastMonth = lastMonth-1;
    myDate.setFullYear (lastYear, lastMont, & #135;)
    If (myDate < = today & & sessione! = 1).
    {
    App.Alert ("Date of expiry reached, sorry!", 1, 0, "ALERT");
    Sessione = 1;
    this.closeDoc (true);
    }

    Basically, what I want is that reached X date of publication (example: 27. July 2010) the document shows an alert 'expiry date reached, sorry!", close the document after you press OK

    And no, please don't tell me to get the rights adobe Manager because I'm on a Mac

    First of all, Adobe has sometimes changed the way JavaScript works for some orders from one version to the other, and the possibility of using 'this.close ()' has been changed.

    You the line "myDate.setFullYear(lastYear,lastMonth,lastDay);" only sets the value of the year and does not take account of the other 2 parameters, because "setFullYear()" does parameter and uses the 1 value to set the full 4-digit year.

    The example script uses 'var finalDate = new Date("3/20/2009");' then why not just create the string value of end date of your variables?

    You can use something like ' var finalDate = new Date (lastMonth + "/" + lastDay + "/" + last year); "to build the string of the date of your variables and strings for separators.

    You did not get the value of the "today" date object

    If you want to change the sample code, you should have the reference for the language material, so you can read what the line of code is supposed to do. Only change a single line of code at a time then and see what happens. In this way, you would have to deal with the error of a change. And if you have a mistake, re-read on the property, method, or function you are trying to use is supposed to do.

  • Need help with an expiration date

    I have as of today on my spreadsheet, need help to make a column of expiry date which will go to the Red 20 days before expiry. Not to find the formula, please help? Thank you.

    Hi Emtsrus,

    Conditional highlighting in column A. Select the cells and then click Conditional highlighting

    Add rule > Dates > in the next

    Another reminder, formula in B2 (and fill down)

    = DATEDIFF (TODAY (), A2, "D")

    Kind regards

    Ian.

  • Need help with java script date

    Hi all

    Using Mac OS 10.6.8 and Adobe Acrobat 9.

    I am working on a form that has course date when you open the form.

    I have a field to enter an earlier date.

    If the effective date is = to or more than 3 years old (1095 days), then it will show a hidden field "sorry your registration has expired.

    If date enered is less than 3 years, then the field remains hidden.

    I have a field to display the result in days, I'm going to hide once the script works.

    Here is the shape right now.

    www.nixmailmac.com/register.PDF

    Any help would be appreciated.

    Ron has

    The code that I provided above is a compacted to if-then-else way. If you really want to, you can use this instead:

    If (event.value< 1095)="">

    getField("Enter_Field_Name_Here").display = display.hidden;

    } else {}

    getField("Enter_Field_Name_Here").display = display.visible;

    }

  • need help with sql query dates

    Hello

    I have a sql query I need to extract some info between data dates. Where clause in this query is:

    WHERE CPD_BUS_UNIT =: ESI_PRM_1
    AND CPD_VOUCHER_DATE > =: P_DATE_FROM
    AND CPD_VOUCHER_DATE < (: P_DATE_TO + 1).

    When I run the query into a toad, I can view the data, but not the execution plan. It gives an error ORA-00932 inconsistent Datatypes.
    But when I remove (+ 1): P_DATE_TO, I can c the execution plan and data. The data will be different from the previous.

    Please suggest how to rewrite the query.

    Can you please give it a try?

    WHERE CPD_BUS_UNIT=:ESI_PRM_1
    AND CPD_VOUCHER_DATE >= :to_date(P_DATE_FROM)
    AND CPD_VOUCHER_DATE < (to_date(:P_DATE_TO)+1) 
    

    Concerning

  • help with query - 4 tables

    looking for help with this query. can't do things.

    4 tables.

    doc_master
    doc_folder_master
    project_master
    doc_relations

    quick overview of tables
    doc_master has all the documents in the files
    doc_folder_master has all the names of folders (documents are in folders)
    project_master has all the names of project
    doc_relations has the relationship between records and documents by file ID and ID of Document.

    try to get all the documents of the doc_master where the project name is '% provider %' I can do it without problem.
    Like this...

    Select * from document_master where proj_id IN
    (select proj_id from project_master where status = 'A' and upper (proj_title) like '% PROVIDER %')


    but now I must also name the folder in each document.

    Try like this, but does not.
    get the same name documents




    Select doc_file_name, name, proj_title from)
    Select * from
    (select * from document_master where proj_id IN)
    (select proj_id from project_master where status = 'A' and upper (proj_title) like '% PROVIDER %')
    ),

    (select * from document_relations) b.

    (select * from doc_folder_master) c,.

    (select * from project_master) d


    where a.doc_id = b.child_doc_id
    and d.proj_id = a.proj_id

    )


    I apologize if I am missing any info. If you need more please let me know.

    Published by: Jay on November 18, 2010 05:26

    So if I understand you

    select a.doc_file_name, c.name, d.proj_title
    from document_master a,
         document_relations b,
         doc_folder_master c,
         project_master d
    where c.doc_folder_id = b.parent_doc_id
      and b.child_doc_id = a.doc_id
      and d.proj_id= a.proj_id
      and d.status='A'
      and upper(d.proj_title) like '%SUPPLIER%'    
    

    If every relationship exists, the query will work.
    If not try an outer join to find the error as

    select a.doc_file_name, c.name, d.proj_title
    from document_master a,
         document_relations b,
         doc_folder_master c,
         project_master d
    where c.doc_folder_id(+) = b.parent_doc_id
      and b.child_doc_id(+) = a.doc_id
      and d.proj_id(+) = a.proj_id
    
  • help with table 1 d research

    Hey guys,.

    IM extracting data from a database and store it as a cluster of tables 1 d and now I want to find an element in a table using the table. After completing the two individual tables I try and seek help search 1 d table comparing to a fourth value has already generated. I was hoping to use the index of table 1 d search to enter something at this level since the other table.

    Table im trying to look for a currently a single element, the element im trying to find, but I get a - 1 return.

    can you see what I'm doing wrong here? is there something I don't understand not all table 1 d search?

    Thank you guys

    A common problem here is white space (spaces, tabs, and newline characters, etc.).  Try to use Whitespace Trim on the search string and the elements of the array before the search.

  • help with this thread using oracle 7.3

    Dear expert;

    On this thread, I am using

    Help with this

    but I'll need help more with additional information in this regard. see examples of data below

    Hello experts.

    I use oracle 7.3. Therefore, I have the sample data below

    create the table table_one

    (

    req_week varchar (1000).

    Username varchar (1000).

    sale number (30),

    place varchar (1000).

    break_sales number (30)

    );

    insert into table_one values ("week 1", 'John', 100, "NY", 2 ").

    insert into table_one values (' week 1', 'Chris', 20, "TX", 3 ')

    insert into table_one values ("week 1", "Melissa", 80, 'GOES', 4 ')

    insert into table_one values (' week 2', 'Katy', 40 'SC', 1 ")

    insert into table_one values (' week 2', 'Angle', 10, 'NC', 2 ')

    insert into table_one values (' week 2', "Vick", 30, 'CA', 3 ')

    insert into table_one values (' week 3', 'Zack', 60 'CA', 1 ")

    insert into table_one values (' week 3', 'Deb', 60 'NM', 2 ')

    insert into table_one values (' week 3', 'Antoine,"60,"TX", 3 ')

    necessary results

    I need the top 2 sales in a place a week

    expected results

    req_week username place sales

    Week1 John 100 NY

    Week1 Melissa 80'S

    Semaine2 Katy 40 SC

    Semaine2 Vick 30 CA

    Semaine3 Zack 60 TX

    Semaine3 Deb 60 NM

    Note, in this particular case, if there is equality in sales, then use the break_sales column as a case. The break_sales was never a tie... it is so far the query and it does not work as expected

    SELECT    d.req_week, d.username, d.sales, d.place
    FROM      nikeus_report.dbo.table_one  d
    ,        nikeus_report.dbo.table_one  o
    WHERE    d.req_week  = o.req_week
    AND      d.sales    <=  o.sales   
    GROUP BY  d.req_week, d.username, d.sales, d.place
    HAVING    COUNT (*)  <= 2         
    ;
    
    

    Any help is appreciated. Thank you

    Hello

    It seems that your existing query is very good, he's going; Just add the conditions for breaking in the WHERE clause:

    SELECT d.req_week

    d.username

    d.sales

    d.place

    FROM table_one d

    table_one o

    WHERE d.req_week = o.req_week

    AND (d.sales< >

    OR (d.sales = o.sales

    AND d.break_sales > = o.break_sales

    )

    )

    GROUP BY d.req_week

    d.username

    d.sales

    d.place

    HAVING COUNT (*)<=>

    ORDER BY d.req_week

    COUNT (*)

    ;

    Thanks for posting the CREATE TABLE and INSERT statements; that really helps.

  • Need help with service of process

    IM currently studying Oracle and SQL im really stuck on this.
    If someone could give me some help it would be greatly appreciated.

    drop table of Property_tab strength;

    drop table of Appointment_tab strength;

    drop table of Person_tab strength;

    Drop type view_list_type force;

    type of force projection Property_type;

    type of force projection Appointment_type;

    type of force projection SalesPerson_type;

    type of force projection Applicant_type;

    type of force projection Person_type;


    create or replace type Person_type;
    /
    create or replace type SalesPerson_type;
    /
    create or replace type Applicant_type;
    /
    create or replace type Appointment_type;
    /
    create or replace type Property_type;
    /
    Create type View_list_type as table ref Appointment_type;
    /

    Create the Person_type type as object)
    IdNo number,
    Name varchar (20),
    First name varchar (20),
    date dateOfBirth) NO FINAL;
    /

    create or replace type SalesPerson_type UNDER person_type)
    officeno number,
    fact View_list_type);
    /

    create type Applicant_type UNDER person_type)
    aAddressLine1 varchar (30),
    aAddressLine2 varchar (30),
    aTown varchar (20),
    Number of contactTel1
    Number of contactTel2
    maxPrice number,
    desiredArea varchar (30),
    take part in View_list_type);
    /

    create or replace type Appointment_type as object)
    Date # number,
    Date of AppDate,
    Number of times,
    appointmentType varchar (10),
    LevelOfInterest varchar (10),
    is_Viewed_by ref Property_type
    );
    /

    Create the Property_type type as object)
    Property # varchar (30),
    dateOfRegistration Date,
    HouseType varchar (30),
    rooms number,
    receptionRooms number,
    bathrooms number,
    Garage number,
    Number of garden,
    regionArea varchar (30),
    pAddressLine1 varchar (30),
    pAddressLine2 varchar (30),
    pCode VarChar (7).
    price an INTEGER,
    RelatesTo View_list_type
    );
    /

    create table (Person_tab of Person_type)
    Key primary IdNo NOT NULL);

    create the table Property_tab of Property_type
    nested table relatesto store like view_Appointment_table;

    create table (Appointment_tab of Appointment_type)
    the scope of (is_Viewed_by) is Property_tab);


    insert into Property_tab
    values (1, 18-sep-09', 'Individual', 4, 1, 2, 1, 2, 'Wales', ' 42 Spooner St', 'Bridgend', 'CF347LS', 120000, View_list_type());

    insert into Property_tab
    values (2, October 21, 10 ', 'Semi-private', 4, 1, 2, 1, 2, 'Wales', ' 44 Spooner St', 'Bridgend', 'CF348LS', 200000, View_list_type());

    insert into Property_tab
    values (3,'1-dec-09', 'Individual', 4, 1, 2, 1, 2, "Wales', ' 42 Roath St", "Cardiff", "CF407RQ", 125000, View_list_type());


    INSERT INTO person_tab VALUES (SalesPerson_type (123, 'Steve', 'Jones', January 12, 76 ', 401, View_list_type()));

    INSERT INTO person_tab VALUES (SalesPerson_type (234, 'Brian', 'Williams', October 18, 85 ', 401, View_list_type()));

    INSERT INTO person_tab VALUES (SalesPerson_type (345, 'John', 'Johnson', February 11, 75 ', 402, View_list_type()));

    INSERT INTO person_tab VALUES (SalesPerson_type (456, 'Mike', 'Adams', ' December 2 81', 402, View_list_type()));


    INSERT INTO person_tab VALUES (Applicant_type (111, 'Marie', 'Michaels', December 16, 81 ', '12 Merthyr RD', 'Mid Glam', 'Bridgend', 0165666123, 0780089623, 250000, 'Bridgend', View_list_type()));

    --------------------------------------------------------------------
    below does not work this is what im stuck on
    --------------------------------------------------------------------

    INSERT INTO Appointment_tab
    SELECT 1, January 12, 12 ', 1203, 'View', 'HIGH '.
    Treat (REF (C) UNDER REF Person_type),
    Treat (REF (D) UNDER REF Person_type),
    REF (E),
    Person_tab C, Person_tab D, Property_tab E
    WHERE process (value AS (C) Person_type). IdNo = 123 AND
    Treat (Person_type AS (D) of the value). IdNo = 111 AND
    E.Property_type. Property # = 1;

    I would always limit O - R for your view interfaces and packages.

    It is normally a good idea to stick to Orthodox relational modeling when it comes to the design of the table.

    Is that what you're looking for?

    SQL> INSERT INTO Appointment_tab
      2  SELECT Appointment_type(
      3        1
      4  ,     TO_DATE('12-JAN-12','DD-MON-RR')
      5  ,     1203
      6  ,     'Viewing'
      7  ,    'HIGH'
      8  ,     REF (E))
      9  FROM  Person_tab C
     10  ,     Person_tab D
     11  ,     Property_tab E
     12  WHERE Treat (Value (C) AS Person_type).IdNo = 123
     13  AND   Treat (value (D) AS Person_type).IdNo = 111
     14  AND   Treat (Value(E) AS Property_type).Property# = 1; 
    
    1 row created.
    
    Elapsed: 00:00:00.03
    SQL>
    SQL> select * from appointment_tab;
    
    APPOINTMENT# APPDATE         TIME APPOINTMEN LEVELOFINT
    ------------ --------- ---------- ---------- ----------
    IS_VIEWED_BY
    ----------------------------------------------------------------------------------
               1 12-JAN-12       1203 Viewing    HIGH
    0000220208B41108491D309848E040440A5B681B61B41108491D2E9848E040440A5B681B61
    

    There must be a mistake somewhere as your type of appointment has no attributes of the applicant/person/sales_person (so there is no point in selecting them with the current definition).

    Published by: Dom Brooks on December 15, 2011 16:40

Maybe you are looking for