selection of required sample query

Hello

example of table can be considered to be table scott.emp

  CREATE TABLE "EMP" 
   (     "EMPNO" NUMBER(4,0), 
     "ENAME" VARCHAR2(10 BYTE), 
     "JOB" VARCHAR2(9 BYTE), 
     "MGR" NUMBER(4,0), 
     "HIREDATE" DATE, 
     "SAL" NUMBER(7,2), 
     "DEPTNO" NUMBER(2,0)
   )

-- INSERTING into EMP
Insert into EMP (EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,DEPTNO) values (7369,'SMITH','CLERK',7902,to_date('17-DEC-80','DD-MON-RR'),800,20);
Insert into EMP (EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,DEPTNO) values (7499,'ALLEN','SALESMAN',7698,to_date('20-FEB-81','DD-MON-RR'),1600,30);
Insert into EMP (EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,DEPTNO) values (7521,'WARD','SALESMAN',7698,to_date('22-FEB-81','DD-MON-RR'),1250,30);
Insert into EMP (EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,DEPTNO) values (7566,'JONES','MANAGER',7839,to_date('02-APR-81','DD-MON-RR'),2975,20);
Insert into EMP (EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,DEPTNO) values (7654,'MARTIN','SALESMAN',7698,to_date('28-SEP-81','DD-MON-RR'),1250,30);
Insert into EMP (EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,DEPTNO) values (7698,'BLAKE','MANAGER',7839,to_date('01-MAY-81','DD-MON-RR'),2850,30);
Insert into EMP (EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,DEPTNO) values (7782,'CLARK','MANAGER',7839,to_date('09-JUN-81','DD-MON-RR'),2450,10);
Insert into EMP (EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,DEPTNO) values (7788,'SCOTT','ANALYST',7566,to_date('19-APR-87','DD-MON-RR'),3000,20);
Insert into EMP (EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,DEPTNO) values (7839,'KING','PRESIDENT',null,to_date('17-NOV-81','DD-MON-RR'),5000,10);
Insert into EMP (EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,DEPTNO) values (7844,'TURNER','SALESMAN',7698,to_date('08-SEP-81','DD-MON-RR'),1500,30);
Insert into EMP (EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,DEPTNO) values (7876,'ADAMS','CLERK',7788,to_date('23-MAY-87','DD-MON-RR'),1100,20);
Insert into EMP (EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,DEPTNO) values (7900,'JAMES','CLERK',7698,to_date('03-DEC-81','DD-MON-RR'),950,30);
Insert into EMP (EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,DEPTNO) values (7902,'FORD','ANALYST',7566,to_date('03-DEC-81','DD-MON-RR'),3000,20);
Insert into EMP (EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,DEPTNO) values (7934,'MILLER','CLERK',7782,to_date('23-JAN-82','DD-MON-RR'),1300,10);
In this we can see that we have all the data to date of employment between February 1, 81 'and February 20, 81'. But the select statement must retrun
values between these days with employment HAVE NULL and empno, mgr, ename, sal as 0, depno can be 0 or a number.

I tried something and I got the count for a few columns. The query goes something like this.

This works on a given range of dates. The two queries below
select rt.business_date,
( select count(ename) from emp  where trunc(hiredate) = trunc(rt.business_date) )  ename ,
( select count(empno) from emp  where trunc(hiredate) = trunc(rt.business_date) )  empno ,
( select count(job) from emp  where trunc(hiredate) = trunc(rt.business_date) )  job,
( select count(mgr) from emp  where trunc(hiredate) = trunc(rt.business_date) )  mgr ,
( select count(deptno) from emp  where trunc(hiredate) = trunc(rt.business_date) )  deptno 
FROM (select ((TO_DATE(p_startdate,'mm/dd/yyyy')-1)+rnm) as business_date from (select rownum rnm from user_objects)) rt
             WHERE TRUNC(rt.business_date) BETWEEN TO_DATE(p_startdate,'mm/dd/yyyy') AND  TO_DATE(p_enddate,'mm/dd/yyyy')
             
        
OUT of the SAMPLE of a statement select should be something like this:
empno     ename      job     mgr     HIREDATE     SAL     DEPTNO     
7369     SMITH     CLERK     7902     17-Dec-80     800     20     
0     NULL     NULL     0     14-Feb-81     0     0     
0     NULL     NULL     0     15-Feb-81     0     0     
0     NULL     NULL     0     16-Feb-81     0     0     
0     NULL     NULL     0     17-Feb-81     0     0     
0     NULL     NULL     0     18-Feb-81     0     0     
0     NULL     NULL     0     19-Feb-81     0     0     
7499     ALLEN     SALESMAN     7698     20-Feb-81     1600     30     
7521     WARD     SALESMAN     7698     22-Feb-81     1250     30     
7566     JONES     MANAGER     7839     2-Apr-81     2975     20     
7698     BLAKE     MANAGER     7839     1-May-81     2850     30     
7782     CLARK     MANAGER     7839     9-Jun-81     2450     10     
7844     TURNER     SALESMAN     7698     8-Sep-81     1500     30     
7654     MARTIN     SALESMAN     7698     28-Sep-81     1250     30     
7839     KING     PRESIDENT     (null)     17-Nov-81     5000     10     
7900     JAMES     CLERK     7698     3-Dec-81     950     30     
7902     FORD     ANALYST     7566     3-Dec-81     3000     20     
7934     MILLER     CLERK     7782     23-Jan-82     1300     10     
7788     SCOTT     ANALYST     7566     19-Apr-87     3000     20     
7876     ADAMS     CLERK     7788     23-May-87     1100     20     
Published by: sri on October 19, 2011 08:36

Published by: sri on October 19, 2011 08:56

Hello

You have changed your first message.

Sri says:
Hello

I want the data in the table appears as shown. in the quereis we get count of these records for that date. But I want something different. If we can see a few dates there is no record, but the select statement to display the records in the range of dates.

put it can be cosnidered something like this:

The need of the select statement to display data hiredates for 14-20 Feb as described below, and that we don't have in our database of emp table.

empno     ename      job     mgr     HIREDATE     SAL     DEPTNO
7369     SMITH     CLERK     7902     17-Dec-80     800     20
0     NULL     NULL     0     14-Feb-81     0     0
0     NULL     NULL     0     15-Feb-81     0     0
0     NULL     NULL     0     16-Feb-81     0     0
0     NULL     NULL     0     17-Feb-81     0     0
0     NULL     NULL     0     18-Feb-81     0     0
0     NULL     NULL     0     19-Feb-81     0     0
7499     ALLEN     SALESMAN     7698     20-Feb-81     1600     30
7521     WARD     SALESMAN     7698     22-Feb-81     1250     30
7566     JONES     MANAGER     7839     2-Apr-81     2975     20
7698     BLAKE     MANAGER     7839     1-May-81     2850     30
7782     CLARK     MANAGER     7839     9-Jun-81     2450     10
7844     TURNER     SALESMAN     7698     8-Sep-81     1500     30
7654     MARTIN     SALESMAN     7698     28-Sep-81     1250     30
7839     KING     PRESIDENT     (null)     17-Nov-81     5000     10
7900     JAMES     CLERK     7698     3-Dec-81     950     30
7902     FORD     ANALYST     7566     3-Dec-81     3000     20
7934     MILLER     CLERK     7782     23-Jan-82     1300     10
7788     SCOTT     ANALYST     7566     19-Apr-87     3000     20
7876     ADAMS     CLERK     7788     23-May-87     1100     20

Use a FULL OUTER JOIN instead of LEFT OUTER JOIN, like this:

WITH     all_dates  AS
(
     SELECT     startdate + LEVEL - 1     AS dt
     FROM     (
               SELECT     TO_DATE ('02/14/1981', 'MM/DD/YYYY')     AS startdate
               ,     TO_DATE ('02/20/1981', 'MM/DD/YYYY')     AS enddate
                FROM     dual
          )
     CONNECT BY     LEVEL <= 1+ enddate - startdate
)
SELECT       NVL (e.empno, 0)          AS empno
,       e.ename
,       NVL (a.dt, e.hiredate)     AS hiredate
--  add other columns
FROM                 all_dates     a
FULL OUTER JOIN      emp          e  ON  a.dt = e.hiredate
ORDER BY  NVL (a.dt, e.hiredate)
;

Tags: Database

Similar Questions

  • ORA-01445: cannot select ROWID, or sample, a view of join without key - preserved table form w/report and LOV

    I create a page "Form on a Table with Report" (APEX 5). Table I has 3 columns: cat_key, item_value, item_description. The cat_key is a foreign key in a table with columns cat_key, cat_value. I created the report and everything works fine.  The page of the report shows my domain cat_key in number, so I want it instead to display the cat_value. I change the field cat_key to a text based on LOV, select my LOV and now when I view the page of report I get the "'ORA-01445: cannot select ROWID from where sample, a join without key preserved table view ' error." The report uses the ROWID as a link to the edit page field.

    If I use the same tables and even shared LOV in a report page interactive, it works fine.

    What I am doing wrong?

    This is a limitation of the IR Apex will rewrite your query to a query that includes the lookup table and the columns. So now you have actually created a query on an inline view, which causes the error. You can see the query apex created when running in debug mode. APEX will join the table of choice with your primary table. For example from one of my IR:

    Select 'ID '...

    "MSL". "" HIS_COUNTRIES "=> my primary table

    ) ) b,

    (select rv_meaning d, rv_low_value r

    of msl_ref_codes_table

    where rv_domain = "JOHN".

    ) L1 = > query My LOV Lookup

    ...

    So, if possible, base your reports and forms on the real primary key, no rowid.

    You can also write the IR query with the search yourself:

    Select T1.rowid...

    of primary_table T1

    look_table L1

    ...

  • Help required to query the fields of the shuttle to Table?

    Hi Experts,

    My needs:

    1. According to the Ship Date query field, the item number should display in the console on the left.
    2. Select some amendments point shuttle from left to right shuttle and press the button.
    3. the article selected our and these details must display in the table.

    Design:

    1 created as query field (entry of Message text) shipping Date.
    2 Shuttle, Shuttle flight beginning and footer (second query button).
    3. the table that contains the article, Description, quantity, and manufacturing details no.

    Question:

    I created a shuttle, the creeping shuttle and the flight of footer, here I mentioned the VO attribute and discovers for the first query that takes place in shipping date and displays the item No.

    By default (without question) the extension numbers is the display in the shuttle leading.

    How to use the fields in the query of the shuttle. Its not that allows you to query the selected fields.

    Help required:

    I need to ship date, then the element of the request should appear in the console of leak, then I need to move some element not in the shuttle leading and click on the second button of the query.

    All required according to the shipping date and the amendments point values (Selected in the shuttle leading) must display in the table.

    Thank you
    Corinne Bertrand

    Pass this date and form a condition, and re-run the LEADVO

    Anne Marie

  • Gel application - "the required samples are not yet acquired.

    Hello

    I have a vi that controls a test bench. The vi was created using Labview 8.6. Vi works fine and controls to the test correctly when running on the pc where it was created in the full version of software development (which is not converted into a stand-alone executable).

    The problem occurs when I create an executable file and try to run it in another pc. Initially the application seems to work ok but then after a random time (anything between 30 seconds and 12 hours), the application starts to turn slowly and then loses communication with the hardware (cDAQ-9178). After what happened when I opened MAX and try to run the task I get an error message that says that «some of the requested samples are not yet acquired...» »

    When the application starts to slow down, I see a reduction of the available physical memory and one of the CPU usage increases to 100%.

    I built the application using Labview 2012 and use MAX 5.3.1 on the pc hosting the executable file.

    Below, I have included a screenshot of the area of the block diagram which is probably more relevant to solve this problem. In MAX, the task is set to continuous samples, 1 k samples read at the rate of 1 k.

    Anyone have any suggestions for me to try please?

    Thank you

    So now, you can try what BCL@Servodan suggested. Create and launch tasks with DAQmx before your loop and see if it helps. Remove the timed loop would be also advised, and you set the sampling frequency before the normal while loop, as in the official example.

    This would not require too much effort and can help...

  • Error: A selection is required in Nested (Cascade or depends) LOV!

    HII

    When I select the first lov and then I select it second display error... .second lov will display the values depend on the first statement select lov it's (cascade or depend on or nested lov)

    This error occurs

    in the module of the Application works properly... but by page fault occur

    Untitled.jpg

    Hello

    Select your second list on the editor page and look in the Properties Inspector, you will see a "Required" property

    Change its value to false and then check it.

    Due to this validation required the second list is not updated and you are not able to see the values in the list

    Ashish

  • Required SQL query

    Hello

    Suppose I need to check the number of records of 30 tables in the oracle database in a particular schema, it may have hundreds of tables.
    How to check with simple sql query.

    I know that under method,

    Select count (*) from
    Table1, table2, table3... table30;

    But I need in format below. If I use Group by we will get but we must specify all 30 tables to groupby, is any alternative group instead of keep all 30 tables


    SELECT TABLENAME, COUNT (*)
    OF table1, table2, table3... table30

    Group of table1, table2, table3... table30;

    Try the following query if all tables are present in the same pattern in the case otherwise you must use dba_tables:

    SELECT
      table_name,
      to_number(
      extractvalue(
          XMLTYPE(
            dbms_xmlgen.getxml('select count(*) c from '||table_name))
        ,'/ROWSET/ROW/C')) count
    FROM
      user_tables
    WHERE table_name IN ('A','B','C')
    ORDER BY table_name;
    
  • NVARCHAR2 column in the select statement of the query


    Hello

    I have table

    xx_test / / DESC

    Name of Type Null

    -------- -------- --------------

    COL1 NOT NULL NVARCHAR2 (100)

    COL2 NOT NULL NVARCHAR2 (100)

    COL3 NOT NULL NVARCHAR2 (100)

    I am able to interview

    Select * from xx_test

    However if the query as

    Select col1 from xx_test

    Then it is in error.

    ORA-00904: "COL1": invalid identifier

    00904, 00000 - '% s: invalid identifier '.

    * Cause:

    * Action:

    Error on line: column 3-131: 13

    Let me know how interrogate NVARCHAR2 column and how can we put in WHERE condition?

    Thank you

    Abhijit

    Abhijit,

    Now that you have already re-created the table, it would be difficult to find the exact cause. But I suspect it could happen due to the creation of table in a way not recommended the use of quotes.

    If you use double quotes while creating the table/column names, you must always use capital letters. Better is not not to use quotes in all. Here is an example of a test that could be the cause of your error.

    SQL > drop table test;

    Deleted table.

    SQL > create table test ("col1" nvarchar2 (200), col2 varchar2 (200));

    Table created.

    SQL > select Col1 from test;

    Select Col1 from test

    *

    ERROR on line 1:

    ORA-00904: "COL1": invalid identifier - it is him you got. Even if there is col1 column in the table, but I'm unable to select due to the bad way to appoint.

    SQL > drop table test;

    Deleted table.

    SQL > create table test ("COL1" nvarchar2 (200), col2 varchar2 (200));

    Table created.

    SQL >

    SQL > select col1 from test;

    no selected line

    The test case above apply to the tables as well.

    Ishan

  • Required update query:

    SQL > CREATE TABLE TEMP (M_NUMBER NUMBER, MESSAGE VARCHAR2 (100), CODE NUMBER);

    Table created.

    SQL > CREATE TABLE OMNIACC (M_NUMBER NUMBER);

    Table created.


    SQL > CREATE TABLE REG (MOBILENO VARCHAR2 (20));

    Table created.

    SQL > DROP TABLE REG is SERVING;

    Deleted table.

    SQL > CREATE TABLE REG (REGM_NUMBER VARCHAR2 (20));

    Table created.

    SQL > CREATE TABLE OMNIACC_APP (M_NUMBER NUMBER);

    Table created.

    SQL > CREATE TABLE REG_APP (REGM_NUMBER VARCHAR2 (20));

    Table created.
    --------------------------------------------
    HOW CAN I DO THIS ONE
    I WANT TO
    WHENEVER OMNIACC_APP REGM_NUMBER NOT IN TEMP TABLE M_NUMBER AND
    REG_APP REGM_NUMBER NOT IN THE TEMPORARY M_NUMBER TABLE AND
    OMNIACC REGM_NUMBER PRESENT IN THE TEMPORARY M_NUMBER TABLE AND
    REG REGM_NUMBER PRESENT IN THE TEMPORARY M_NUMBER TABLE
    SO I have TO update THE ERRORMESSAGE of TEMPORARY TABLE WITH "M_NUMBER NOT EXIST" FOR ALL THE RECORDS FROM THE TEMPORARY TABLE

    -------------------

    Hello

    If I understand your requirement, this should be the statement:

    UPDATE temp t
       SET t.message='regm_number not exists'
     WHERE EXISTS (SELECT 1
                     FROM omniacc a, reg b
                    WHERE a.m_number=b.regm_number and a.m_number=t.m_number
                      AND NOT EXISTS (SELECT 1
                                        FROM omniacc_app c
                                       WHERE c.m_number=t.m_number)
                      AND NOT EXISTS (SELECT 1
                                        FROM reg_app d
                                       WHERE d.regm_number=t.m_number)
                  );
    
    SELECT * FROM temp;
    
      M_NUMBER MESSAGE                         CODE
    ---------- ------------------------- ----------
        123342
        435251
        425151
        654637 regm_number not exists
       1545778 regm_number not exists
       5475467                                     
    

    Kind regards.
    Al

  • Extraction of a node in an XMLtype table - selection of the previous query

    Hey all,.

    I work with a server Oracle 11 g r2 and basically need to be able to analyse and select nodes from it. I spent hours scouring the net and reading the manual oracle xml db trying to find an appropriate solution to my problem, but I can't seem to identify the correct way to do it. I have some experience in programming, but none with databases oracle, sql or xml in general so forgive me if this is a trivial question.

    OK, so the question:

    I have a very simple XML file saved under catalog.xml and it is as follows:

    <>Catalog
    < cd >
    < title > hide your heart < /title >
    < artist > Bonnie Tyler < / artist >
    < Country > UK < / country >
    < company > CBS Records < / company >
    < price > 9.90 < / price >
    < year > 1988 < / year >
    < CD >
    < cd >
    Empire Burlesque < title > < /title >
    < artist > Bob Dylan < / artist >
    < country > USA < / country >
    < company > Columbia < / company >
    < price > 10.90 < / price >
    < year > 1985 < / year >
    < CD >
    < / catalogue >

    Now, I want to be able to extract the title of the given cd a certain artist. So, for example, if the artist is "bob dylan", the title should be "empire burlesque".

    Now I created an XMLType table in Oracle as follows:

    CREATE BINARY XMLTYPE STORE AS XML BINARY XMLType TABLE.

    I then load my xml file into oracle by:

    Insert the BINARY values (XMLTYPE (BFILENAME ('XML_DIR', 'catalog.xml'), nls_charset_id ('AL32UTF8')));

    So far so good.

    Now for the part of the excerpt:

    First of all I've tried:

    SELECT extract (b.object_value, ' / catalogue/cd/title ')
    Binary b
    WHERE existsNode (b.object_value,'/catalog/cd [artist = "Bob Dylan"]') = 1;

    EXTRACT(B.OBJECT_VALUE,'/CATALOG/CD/TITLE')
    --------------------------------------------------------------------------------

    < title > hide your heart < /title >
    Burlesque Empire < title > < /title >

    1 selected line.



    It did not work because the xml file was all in 1 row then I realized that I had to split my xml in separate rows. Doing that, I had to convert the nodes < title > a virtual table using the functions XMLSequence() and table(). These functions convert nodes two title returned by the extract() function in a virtual table composed of two XMLType objects, each of which contains a single title element.

    Second test:

    SELECT value (d)
    Binary B,
    Table (xmlsequence(extract(b.object_value,'/catalog/cd'))) d
    WHERE existsNode (b.object_value,'/catalog/cd [artist = "Bob Dylan"]') = 1;

    VALUE (D)
    --------------------------------------------------------------------------------

    < cd >
    < title > hide your heart < /title >
    < artist > Bonnie Tyler < / artist >
    < Country > UK < / country >
    < company > CBS Records < / company >
    < price > 9.90 < / price >
    < year > 1988 < / year >
    < CD >

    < cd >
    Empire Burlesque < title > < /title >
    < artist > Bob Dylan < / artist >
    < country > USA < / country >
    < company > Columbia < / company >
    < price > 10.90 < / price >
    < year > 1985 < / year >
    < CD >

    2 selected lines.


    It's better because it is now divided into 2 different lines so I should be able to make a selection - where, and then select the title from the artist.

    However, this is where I have questions, I tried to literally hours but I can't understand how to use the results of the query above in my next. So I tried to use a suquery in this way:

    Select extract (sub1, ' cd/title')
    Of
    (
    SELECT value (d)
    Binary B,
    Table (xmlsequence(extract(b.object_value,'/catalog/cd'))) d
    ) sub1
    WHERE existsNode (sub1,'/ cd [artist = "Bob Dylan"]') = 1;

    However, sql * plus displays an error:

    ORA-00904: "SUB1": invalid identifier.

    I've tried dozens of variations to try to use subqueries but I simly can't do things.

    I heard you can do also do this using variables or pl/sql, but I don't know where to start.

    Any help would be greatly appreciated I tried everything at my disposal.

    This should help you get started!

    select banner as "Oracle version" from v$version where banner like 'Oracle%';
    
    create table otn5test(
      id number,
      data xmltype
    );
    
    insert into otn5test values (1, xmltype('
    
    Hide your heart
    Bonnie Tyler
    UK
    CBS Records
    9.90
    1988
    
    
    Empire Burlesque
    Bob Dylan
    USA
    Columbia
    10.90
    1985
    
    
    '));
    
    select otn5test.id, x.*
    from otn5test,
         xmltable('/catalog/cd[artist/text()="Bob Dylan"]' passing otn5test.data
         columns title varchar2(20) path 'title') x;
    
    select otn5test.id,
           xmlcast(xmlquery('/catalog/cd[artist/text()="Bob Dylan"]/title'
                   passing otn5test.data returning content)
           as varchar2(20)) from otn5test;
    
    drop table otn5test;
    
    sqlplus> @otn-5.sql
    
    Oracle version
    ------------------------------------------------------------------------------
    Oracle Database 11g Release 11.2.0.1.0 - 64bit Production
    
    Table created.
    
    1 row created.
    
         ID TITLE
    ---------- --------------------
          1 Empire Burlesque
    
         ID XMLCAST(XMLQUERY('/C
    ---------- --------------------
          1 Empire Burlesque
    
    Table dropped.
    
  • Please send me selection for the following query statement...

    FOR I IN 1.9 LOOP
    IF shift (i) IS NULL THEN
    FOR y IN i + 1.9 LOOP
    IF shift (y) IS NOT NULL THEN
    (I) shift: shift = (y);
    Shift (y): = NULL;
    EXIT;
    END IF;
    END LOOP;
    END IF;
    END LOOP;



    Please how to write the select query to replace the lines of code above

    Please proceed here complete and this code did SHIFT here.

  • Select the required output request

    Hello

    SELECT CUREPRESS, PRODUCTIONCODE, YYYYMMDD STARTDATE.
    CASE
    WHEN annex 1 = 0 AND SCHEDULE2 = 0 AND schedule3 > 0 AND ROUND(30-SCHEDULE3/CURECAPACITY*24,0) > 24 THEN
    ROUND (30-(CALENDRIER3/CURECAPACITY * 24), 0) - 24
    WHEN annex 1 = 0 AND SCHEDULE2 = 0 AND schedule3 > 0 AND ROUND(30-SCHEDULE3/CURECAPACITY*24,0) < = 24 THEN
    ROUND(30-SCHEDULE3/CURECAPACITY*24,0)
    WHEN annex 1 = 0 AND > 0-> 0 THEN schedule3 SCHEDULE2
    ROUND(22-SCHEDULE2/CURECAPACITY*24,0)
    WHEN annex 1 > 0-> 0-> 0 THEN schedule3 SCHEDULE2
    ROUND(14-SCHEDULE1/CURECAPACITY*24,0)
    END STARTDATE1
    DE)
    SELECT curepress, PRODUCTIONCODE, YYYYMMDD, annex 1, schedule2, schedule3, curecapacity
    OF ORGCURESCHEDULEDAY HAS
    WHERE YYYYMMDD = (SELECT MIN (YYYYMMDD)
    OF ORGCURESCHEDULEDAY B
    WHERE A.PRODUCTIONCODE = B.PRODUCTIONCODE
    AND A.CUREPRESS = B.CUREPRESS)
    ) GROUP OF PRODUCTIONCODE, CUREPRESS, YYYYMMDD, ANNEX 1, SCHEDULE2, SCHEDULE3, CURECAPACITY
    ORDER OF CUREPRESS, PRODUCTIONCODE

    The above query gives the values in column 4 as... !!

    curepress productioncode startdate1 startdate

    0101 IO72A 20110412 22-> case statement gives this value as startdate1
    0101 20110221 6 OQ36A

    I want to display the output as startdate1 (startdate + statedate1)

    curepress productioncode startdate1 startdate

    0101 20110412 20110412 22.00 IO72A
    0101 OQ36A 20110221 20110221 06.00

    Please help me...!

    concerning
    Valérie

    Please do not duplicate your questions.

    Select the query gives error

    Locking this thread.

  • selection of values to query where clause

    Hi guys, it of maybe a silly question but do not know if I approach the solution in the correct engineering.

    At the top of my form, I framed that the user fills out the different values. These values are then used to refine the query results in the block below. I know that I can go in the datablock being interrogated and set the where the clause equal to the value of the text boxes above, but I don't feel it is the right place to do it.

    If I do like this when the above text box is empty, it returns no results when infact I want to ask all if the values are left white. So should I put it in motion pre? If so how should we do?

    Any help would be greatly appreciated.

    Thank you.

    In the trigger of the QUERY before block you, just put the value in the corresponding element

      :block.name := :ctrl.selection ;
    

    François

  • Required matrix query suggestion

    create table car_plant (partno varchar2 (5) number of KM_RUN (10), accident_count number (10));

    AFTER CREATION, ADD a FEW LINES so that

    SELECT * FROM CAR_PLANT
    PARTNO KM_RUN ACCIDENT_COUNT

    1000 2 P1
    2000 5 P1
    1000 2 P2
    2000 4 P2
    6 3000 P2



    I WANT THE RESULT OF THE QUERY LIKE THIS


    KM_RUN P1 P2
    1000 2 2
    2000 5 4
    6 0 3000


    Could someone work on that. This seems to be complicated because... I give 2 plants... P1 AND P2. Currently, there are 150 plants. P1, P2... P150

    Pls try this and give me a good solution

    S

    A bit messy and no doubt horribly inefficient but you might tweak it a bit...

    WITH car_plant AS
    (
        SELECT 'P1' AS PARTNO, 1000 AS KM_RUN, 2 AS ACCIDENT_COUNT FROM DUAL UNION ALL
        SELECT 'P1' AS PARTNO, 2000 AS KM_RUN, 5 AS ACCIDENT_COUNT FROM DUAL UNION ALL
        SELECT 'P2' AS PARTNO, 1000 AS KM_RUN, 2 AS ACCIDENT_COUNT FROM DUAL UNION ALL
        SELECT 'P2' AS PARTNO, 2000 AS KM_RUN, 4 AS ACCIDENT_COUNT FROM DUAL UNION ALL
        SELECT 'P2' AS PARTNO, 3000 AS KM_RUN, 6 AS ACCIDENT_COUNT FROM DUAL
    ),
    -- END OF TEST DATA
    cols AS
    (
        SELECT distinct partno FROM car_plant
    ),
    rws AS
    (
        SELECT distinct km_run FROM car_plant
    ),
    data AS
    (
        SELECT rws.km_run,
               cols.partno,
               car_plant.accident_count,
               row_number() over (partition by rws.km_run order by cols.partno) AS rn,
               count(*) over (partition by rws.km_run) AS c,
               dense_rank() over (order by rws.km_run) AS dr
        FROM rws
        CROSS JOIN cols
        LEFT OUTER JOIN car_plant ON (car_plant.partno = cols.partno AND car_plant.km_run = rws.km_run)
    )
    SELECT km_run, txt
    FROM
    (
        SELECT rn,
               c,
               dr,
               null AS km_run,
               CAST(sys_connect_by_path(rpad(partno, 5, ' '), '|') AS VARCHAR2(100)) AS txt
        FROM data
        START WITH rn = 1
        CONNECT BY rn = PRIOR rn + 1 and km_run = PRIOR km_run
    )
    WHERE rn = c AND dr = 1
    UNION ALL
    SELECT km_run, txt
    FROM
    (
        SELECT rn,
               c,
               km_run,
               CAST(sys_connect_by_path(rpad(nvl(to_char(accident_count), ' '), 5, ' '), '|') AS VARCHAR2(100)) AS txt
        FROM data
        START WITH rn = 1
        CONNECT BY rn = PRIOR rn + 1 AND km_run = PRIOR km_run
    )
    WHERE  rn = c
    ORDER BY km_run NULLS FIRST
    /
    
    KM_RUN                 TXT
    ---------------------- ----------------------------------------------------------------------------------------------------
                           |P1   |P2
    1000                   |2    |2
    2000                   |5    |4
    3000                   |     |6                                                                                             
    

    Wish I had an 11g database available to me... I think listagg, it would have been easier.

    Published by: Cyn on October 28, 2009 10:29

  • Select the 1st successful query

    Hi guy,



    How to choose a first non-zero in the Group of sql query?


    for example


    Select a, b, c of

    (select a, b, c, x, where a = 'c')
    Select a, b, c of is where a = 'c '.
    Select a, b, c of z, where a = 'c '.
    )

    by 3 querys in a sub block, I select the first query executed successfully.

    Thank you.


    REDA

    Published by: infant_raj on May 20, 2009 03:53

    Published by: infant_raj on May 20, 2009 03:56

    Hello
    If the first query doesnot return a line, then the second query of the UNION will be executed.
    If the second query returns all data, and then those that will be shown, and similarly the third search also.

    You ran the query?

    The last sub query, change the names of the tables to x and y instead of y and z

    the names of the tables in the change request

    Published by: Anthony Alix on May 20, 2009 05:03

    Published by: Anthony Alix on May 20, 2009 05:08

  • Select and hide the query

    In Photoshop CC when I use select and hide the 'onion skin' filter does only rarely. Any suggestions as to why this could be?

    Works perfectly! I'm wondering now if I had the - ticked instead of +. Seems as if could be the answer and if it does not work in the future I'll check everything here first. Thanks for your time and your help.

Maybe you are looking for