Need Help for SQL Subqueries

Hi,
I want to generate material wise stock report.
Report must contain the following
CNT_DESC TOTAL_BAGS TOTAL_WEIGHT
I am getting the correct result. But i have a doubt. Is there any other efficient or optimal query for solving this?
The followings are the query to retrieve data.
SELECT CT.cnt_count,
       NVL(
                  SELECT SUM(lvyp_weight)
               FROM tb_lvm_yarnprod
               WHERE lvyp_deleted= 'N'
               AND lvyp_countno = CT.cnt_seqno
               AND lvyp_proddate <= TO_DATE('28/12/2008', 'dd/mm/yyyy')
            0
          )AS PROD,
        NVL
            SELECT SUM(lvyp_nbags)
            FROM tb_lvm_yarnprod
            WHERE lvyp_deleted= 'N'
            AND lvyp_countno = CT.cnt_seqno
            AND lvyp_proddate <= TO_DATE('28/12/2008', 'dd/mm/yyyy')
         0
        )AS PRODBAGS,
       NVL
            SELECT SUM(lypd_weight)
            FROM tb_lvm_yarnpurchase, tb_lvm_yarnpurchasedet
            WHERE lyp_deleted='N'
            AND lypd_seqno_fk= lyp_seqno_pk
            AND lypd_countno = CT.cnt_seqno
            AND lyp_date <= TO_DATE('28/12/2008', 'dd/mm/yyyy')
        0
       )AS PUR,
       NVL
            SELECT SUM(lypd_nbags)
            FROM tb_lvm_yarnpurchase, tb_lvm_yarnpurchasedet
            WHERE lyp_deleted='N'
            AND lypd_seqno_fk= lyp_seqno_pk
            AND lypd_countno = CT.cnt_seqno
            AND lyp_date <= TO_DATE('28/12/2008', 'dd/mm/yyyy')
        0
       )AS PURBAGS,
       NVL
            SELECT SUM(lysrd_weight)
            FROM tb_lvm_yarnsalesret, tb_lvm_yarnsalesretdet
            WHERE lysr_deleted='N'
            AND lysrd_seqno_fk=lysr_seqno_pk
            AND lysrd_countno=CT.cnt_seqno
            AND lysr_date <= TO_DATE('28/12/2008', 'dd/mm/yyyy')
        0
       )AS SALERET,
       NVL
            SELECT SUM(lysrd_nbags)
            FROM tb_lvm_yarnsalesret, tb_lvm_yarnsalesretdet
            WHERE lysr_deleted='N'
            AND lysrd_seqno_fk=lysr_seqno_pk
            AND lysrd_countno=CT.cnt_seqno
            AND lysr_date <= TO_DATE('28/12/2008', 'dd/mm/yyyy')
        0
       )AS SALERETBAGS,
       NVL
            SELECT SUM(lyrkd_weight)
            FROM tb_lvm_yarnretfromknit, tb_lvm_yarnretfromknitdet
            WHERE lyrk_deleted='N'
            AND lyrkd_seqno_fk = lyrk_seqno_pk
            AND lyrkd_countno =CT.cnt_seqno
            AND lyrk_date <= TO_DATE('28/12/2008', 'dd/mm/yyyy')
        0
       )AS RETKNIT,
       NVL
            SELECT SUM(lyrkd_nbags)
            FROM tb_lvm_yarnretfromknit, tb_lvm_yarnretfromknitdet
            WHERE lyrk_deleted='N'
            AND lyrkd_seqno_fk = lyrk_seqno_pk
            AND lyrkd_countno =CT.cnt_seqno
            AND lyrk_date <= TO_DATE('28/12/2008', 'dd/mm/yyyy')
        0
       )AS RETKNITBAGS,
       NVL
            SELECT SUM(lysd_weight)
            FROM tb_lvm_yarnsales, tb_lvm_yarnsalesdet
            WHERE lys_deleted='N'
            AND lysd_seqno_fk = lys_seqno_pk
            AND lysd_countno=CT.cnt_seqno
            AND lys_date <= TO_DATE('28/12/2008', 'dd/mm/yyyy')
        0
       )AS SALE,
       NVL
            SELECT SUM(lysd_bags)
            FROM tb_lvm_yarnsales, tb_lvm_yarnsalesdet
            WHERE lys_deleted='N'
            AND lysd_seqno_fk = lys_seqno_pk
            AND lysd_countno=CT.cnt_seqno
            AND lys_date <= TO_DATE('28/12/2008', 'dd/mm/yyyy')
        0
       )AS SALEBAGS,
       NVL
            SELECT SUM(yissd_weight)
            FROM tb_lvm_yarnissue, tb_lvm_yarnissuedet
            WHERE yiss_deleted='N'
            AND yissd_countno =CT.cnt_seqno
            AND yiss_date <= TO_DATE('28/12/2008', 'dd/mm/yyyy')
        0
       )AS ISS,
       NVL
            SELECT SUM(yissd_nbags)
            FROM tb_lvm_yarnissue, tb_lvm_yarnissuedet
            WHERE yiss_deleted='N'
            AND yissd_countno =CT.cnt_seqno
            AND yiss_date <= TO_DATE('28/12/2008', 'dd/mm/yyyy')
        0
       )AS ISSBAGS
       FROM tb_lvm_counts CT 
       ORDER BY CT.cnt_count;TOTAL_BAGS = (PROD + PUR + SALERET + RETKNIT) - (SALE + ISS)
TOTAL_WEIGHT = (PRODBAGS + PURBAGS + SALERETBAGS + RETKNITBAGS) - (SALEBAGS + ISSBAGS)
Will it get slow, while data gets increased? Is there any other efficient way for solving the above?
Thanks & Regards

Hi,
Thank you for all your valuable replies....
See the followings are the table design... I hope now you can understand clearly...
SQL> desc tb_lvm_counts;
Name                                      Null?    Type
CNT_COUNT                                          VARCHAR2(20)
CNT_SEQNO                                 NOT NULL NUMBER
SQL> desc tb_lvm_yarnprod;
Name                                      Null?    Type
LVYP_SEQNO_PK                             NOT NULL NUMBER
LVYP_PRODDATE                             NOT NULL DATE
LVYP_COUNTNO                              NOT NULL NUMBER
LVYP_LOTNO                                         VARCHAR2(5)
LVYP_NBAGS                                         NUMBER
LVYP_WEIGHT                               NOT NULL NUMBER(13,3)
LVYP_BAGNO                                         VARCHAR2(15)
LVYP_DELETED                                       VARCHAR2(1)
SQL> desc tb_lvm_yarnpurchase;
Name                                      Null?    Type
LYP_SEQNO_PK                              NOT NULL NUMBER
LYP_INVNO                                 NOT NULL VARCHAR2(15)
LYP_PARTYNO                               NOT NULL NUMBER
LYP_JOBNO                                 NOT NULL VARCHAR2(10)
LYP_INVAMOUNT                                      NUMBER(12,2)
LYP_RCPDATE                               NOT NULL DATE
LYP_DATE                                  NOT NULL DATE
LYP_VEHNO                                          VARCHAR2(15)
LYP_FREIGHT                                        NUMBER
LYP_DELETED                                        VARCHAR2(1)
SQL> desc tb_lvm_yarnpurchasedet;
Name                                      Null?    Type
LYPD_SEQNO_FK                             NOT NULL NUMBER
LYPD_COUNTNO                              NOT NULL NUMBER
LYPD_NBAGS                                         NUMBER
LYPD_LOTNO                                         VARCHAR2(5)
LYPD_WEIGHT                               NOT NULL NUMBER(13,3)
LYPD_SEQNO_PK                             NOT NULL NUMBER
SQL> desc tb_lvm_yarnsalesret;
Name                                      Null?    Type
LYSR_SEQNO_PK                             NOT NULL NUMBER
LYSR_INVNO                                NOT NULL VARCHAR2(10)
LYSR_PARTYNO                              NOT NULL NUMBER
LYSR_JOBNO                                NOT NULL VARCHAR2(15)
LYSR_RCPDATE                              NOT NULL DATE
LYSR_DATE                                 NOT NULL DATE
LYSR_REMARKS                                       VARCHAR2(100)
LYSR_DELETED                                       VARCHAR2(1)
SQL> desc tb_lvm_yarnsalesretdet;
Name                                      Null?    Type
LYSRD_SEQNO_FK                            NOT NULL NUMBER
LYSRD_COUNTNO                             NOT NULL NUMBER
LYSRD_LOTNO                                        VARCHAR2(5)
LYSRD_NBAGS                                        NUMBER
LYSRD_WEIGHT                              NOT NULL NUMBER(13,3)
LYSRD_SEQNO_PK                            NOT NULL NUMBER
SQL> desc tb_lvm_yarnretfromknit;
Name                                      Null?    Type
LYRK_SEQNO_PK                             NOT NULL NUMBER
LYRK_DCNO                                 NOT NULL VARCHAR2(15)
LYRK_DATE                                 NOT NULL DATE
LYRK_REMARKS                                       VARCHAR2(100)
LYRK_DELETED                                       VARCHAR2(1)
SQL> desc tb_lvm_yarnretfromknitdet;
Name                                      Null?    Type
LYRKD_SEQNO_FK                            NOT NULL NUMBER
LYRKD_COUNTNO                             NOT NULL NUMBER
LYRKD_LOTNO                                        VARCHAR2(5)
LYRKD_NBAGS                                        NUMBER
LYRKD_WEIGHT                              NOT NULL NUMBER(13,3)
LYRKD_SEQNO_PK                            NOT NULL NUMBER
SQL> desc tb_lvm_yarnsales;
Name                                      Null?    Type
LYS_SEQNO_PK                              NOT NULL NUMBER
LYS_INVNO                                 NOT NULL VARCHAR2(15)
LYS_PARTYNO                               NOT NULL NUMBER
LYS_JOBNO                                 NOT NULL VARCHAR2(10)
LYS_DATE                                  NOT NULL DATE
LYS_BAGNO                                          VARCHAR2(10)
LYS_DELETED                                        VARCHAR2(1)
SQL> desc tb_lvm_yarnsalesdet;
Name                                      Null?    Type
LYSD_SEQNO_FK                             NOT NULL NUMBER
LYSD_COUNTNO                              NOT NULL NUMBER
LYSD_LOTNO                                         VARCHAR2(5)
LYSD_BAGS                                          NUMBER
LYSD_WEIGHT                               NOT NULL NUMBER(13,3)
LYSD_SEQNO_PK                             NOT NULL NUMBER
SQL> desc tb_lvm_yarnissue;
Name                                      Null?    Type
YISS_PONO                                 NOT NULL VARCHAR2(10)
YISS_DCNO                                 NOT NULL VARCHAR2(10)
YISS_DATE                                 NOT NULL DATE
YISS_SEQNO                                NOT NULL NUMBER
YISS_DATETIME                                      DATE
YISS_DELETED                                       VARCHAR2(1)
YISS_BAGNO                                         VARCHAR2(15)
SQL> desc tb_lvm_yarnissuedet;
Name                                      Null?    Type
YISSD_SEQNO_FK                            NOT NULL NUMBER
YISSD_LOT                                          VARCHAR2(5)
YISSD_COUNTNO                             NOT NULL NUMBER
YISSD_WEIGHT                              NOT NULL NUMBER(13,3)
YISSD_SEQNO_PK                            NOT NULL NUMBER
YISSD_NBAGS                                        NUMBERThanks & Regards

Similar Messages

  • Need help for sql statement

    Hi,
    Need help to write sql statement.
    create table t_dt ( dt_start date, dt_end date, amount number);
    insert into t_dt values('1-Jan-10','10-Feb-10',12);
    insert into t_dt values('11-Feb-10','10-Mar-10',10);
    insert into t_dt values('11-Mar-10','20-Apr-10',8);
    insert into t_dt values('21-Apr-10','28-Jun-10',10);
    insert into t_dt values('29-Jun-10','20-Sep-10',10);
    insert into t_dt values('21-Sep-10','10-Oct-10',10);
    insert into t_dt values('11-Oct-10','31-Dec-10',8);
    insert into t_dt values('1-Jan-11','10-Feb-11',8);
    insert into t_dt values('11-Feb-11','10-Mar-11',7);
    insert into t_dt values('11-Mar-11','20-Apr-11',6);
    insert into t_dt values('21-Apr-11','28-Jun-11',6);
    insert into t_dt values('29-Jun-11','20-Sep-11',6);
    insert into t_dt values('21-Sep-11','10-Oct-11',4);
    insert into t_dt values('11-Oct-11','31-Dec-11',8);
    Result should be like below..
    dt_start     dt_end     Amount
    1-Jan-10     10-Feb-10     12
    11-Feb-10     10-Mar-10     10
    11-Mar-10     20-Apr-10     8
    21-Apr-10     10-Oct-10     10
    11-Oct-10     10-Feb-11     8
    11-Feb-11     10-Mar-11     7
    11-Mar-11     20-Sep-11     6
    21-Sep-11     10-Oct-11     4
    11-Oct-11     31-Dec-11     8
    Just to explain the example, take a row with start date as 21-Apr-10 in the above insert statements, since it has the same amount for next two rows (i.e. with start date '29-Jun-10' and '21-Sep-10') these 3 rows should be converted to represent only 1 row in the result and the start date and end date should be changed per the result shown above.
    Thanks.

    Hello
    I think this gives yuo what you need....
    SELECT
        MIN(dt_start),
        MAX(dt_end),
        amount
    FROM
        (   SELECT
                dt_start,
                dt_end,
                MAX(marker) OVER(ORDER BY dt_start) marker,
                amount
            FROM
                    Select
                        dt_start,
                        dt_end,
                        amount,
                        CASE
                            WHEN LAG(amount) OVER(ORDER BY dt_start) <> amount THEN
                                ROW_NUMBER() OVER(ORDER BY dt_start)
                        END marker
                    from t_dt
    GROUP BY
         amount,
         marker
    order by     
         MIN(dt_start)
    MIN(DT_START)        MAX(DT_END)              AMOUNT
    01-JAN-2010 00:00:00 10-FEB-2010 00:00:00         12
    11-FEB-2010 00:00:00 10-MAR-2010 00:00:00         10
    11-MAR-2010 00:00:00 20-APR-2010 00:00:00          8
    21-APR-2010 00:00:00 10-OCT-2010 00:00:00         10
    11-OCT-2010 00:00:00 10-FEB-2011 00:00:00          8
    11-FEB-2011 00:00:00 10-MAR-2011 00:00:00          7
    11-MAR-2011 00:00:00 20-SEP-2011 00:00:00          6
    21-SEP-2011 00:00:00 10-OCT-2011 00:00:00          4
    11-OCT-2011 00:00:00 31-DEC-2011 00:00:00          8
    9 rows selected.HTH
    David
    Edited by: Bravid on Feb 23, 2012 12:08 PM
    Beaten to it by Frank! :-)

  • Need help for SQL SELECT query to fetch XML records from Oracle tables having CLOB field

    Hello,
    I have a scenario wherein i need to fetch records from several oracle tables having CLOB fields(which is holding XML) and then merge them logically to form a hierarchy XML. All these tables are related with PK-FK relationship. This XML hierarchy is having 'OP' as top-most root node and ‘DE’ as it’s bottom-most node with One-To-Many relationship. Hence, Each OP can have multiple GM, Each GM can have multiple DM and so on.
    Table structures are mentioned below:
    OP:
    Name                             Null                    Type        
    OP_NBR                    NOT NULL      NUMBER(4)    (Primary Key)
    OP_DESC                                        VARCHAR2(50)
    OP_PAYLOD_XML                           CLOB       
    GM:
    Name                          Null                   Type        
    GM_NBR                  NOT NULL       NUMBER(4)    (Primary Key)
    GM_DESC                                       VARCHAR2(40)
    OP_NBR               NOT NULL          NUMBER(4)    (Foreign Key)
    GM_PAYLOD_XML                          CLOB   
    DM:
    Name                          Null                    Type        
    DM_NBR                  NOT NULL         NUMBER(4)    (Primary Key)
    DM_DESC                                         VARCHAR2(40)
    GM_NBR                  NOT NULL         NUMBER(4)    (Foreign Key)
    DM_PAYLOD_XML                            CLOB       
    DE:
    Name                          Null                    Type        
    DE_NBR                     NOT NULL           NUMBER(4)    (Primary Key)
    DE_DESC                   NOT NULL           VARCHAR2(40)
    DM_NBR                    NOT NULL           NUMBER(4)    (Foreign Key)
    DE_PAYLOD_XML                                CLOB    
    +++++++++++++++++++++++++++++++++++++++++++++++++++++
    SELECT
    j.op_nbr||'||'||j.op_desc||'||'||j.op_paylod_xml AS op_paylod_xml,
    i.gm_nbr||'||'||i.gm_desc||'||'||i.gm_paylod_xml AS gm_paylod_xml,
    h.dm_nbr||'||'||h.dm_desc||'||'||h.dm_paylod_xml AS dm_paylod_xml,
    g.de_nbr||'||'||g.de_desc||'||'||g.de_paylod_xml AS de_paylod_xml,
    FROM
    DE g, DM h, GM i, OP j
    WHERE
    h.dm_nbr = g.dm_nbr(+) and
    i.gm_nbr = h.gm_nbr(+) and
    j.op_nbr = i.op_nbr(+)
    +++++++++++++++++++++++++++++++++++++++++++++++++++++
    I am using above SQL select statement for fetching the XML records and this gives me all related xmls for each entity in a single record(OP, GM, DM. DE). Output of this SQL query is as below:
    Current O/P:
    <resultSet>
         <Record1>
              <OP_PAYLOD_XML1>
              <GM_PAYLOD_XML1>
              <DM_PAYLOD_XML1>
              <DE_PAYLOD_XML1>
         </Record1>
         <Record2>
              <OP_PAYLOD_XML2>
              <GM_PAYLOD_XML2>
              <DM_PAYLOD_XML2>
              <DE_PAYLOD_XML2>
         </Record2>
         <RecordN>
              <OP_PAYLOD_XMLN>
              <GM_PAYLOD_XMLN>
              <DM_PAYLOD_XMLN>
              <DE_PAYLOD_XMLN>
         </RecordN>
    </resultSet>
    Now i want to change my SQL query so that i get following output structure:
    <resultSet>
         <Record>
              <OP_PAYLOD_XML1>
              <GM_PAYLOD_XML1>
              <GM_PAYLOD_XML2> .......
              <GM_PAYLOD_XMLN>
              <DM_PAYLOD_XML1>
              <DM_PAYLOD_XML2> .......
              <DM_PAYLOD_XMLN>
              <DE_PAYLOD_XML1>
              <DE_PAYLOD_XML2> .......
              <DE_PAYLOD_XMLN>
         </Record>
         <Record>
              <OP_PAYLOD_XML2>
              <GM_PAYLOD_XML1'>
              <GM_PAYLOD_XML2'> .......
              <GM_PAYLOD_XMLN'>
              <DM_PAYLOD_XML1'>
              <DM_PAYLOD_XML2'> .......
              <DM_PAYLOD_XMLN'>
              <DE_PAYLOD_XML1'>
              <DE_PAYLOD_XML2'> .......
              <DE_PAYLOD_XMLN'>
         </Record>
    <resultSet>
    Appreciate your help in this regard!

    Hi,
    A few questions :
    How's your first query supposed to give you an XML output like you show ?
    Is there something you're not telling us?
    What's the content of, for example, <OP_PAYLOD_XML1> ?
    I don't think it's a good idea to embed the node level in the tag name, it would make much sense to expose that as an attribute.
    What's the db version BTW?

  • Need help for SQL Queries Tunning

    hi all,
    we have a procedure for search consumers, which using sql queries like:
    SELECT TRIM (NAME) AS NAME, TRIM (accno) AS accno,
    TRIM (connaddress) AS connaddress,
    TRIM (CATEGORY) AS CATEGORY, TRIM (landmark) AS landmark,
    SUBSTR (accno, 1, 3) AS subdivisionname
    FROM consumermaster
    WHERE LOWER (accno) LIKE
    LOWER ('%' || NVL (caccno, '#noval#') || '%')
    OR LOWER (NAME) LIKE LOWER ('%' || NVL (cname, '#noval#') || '%')
    OR LOWER (connaddress) LIKE
    LOWER ('%' || NVL (cadd, '#noval#') || '%')
    OR phone LIKE '%' || NVL (cphone, '#noval#') || '%'
    OR accno = (SELECT accno
    FROM requestregistration
    WHERE requestid = creqid)
    UNION
    SELECT TRIM (NAME) AS NAME, TRIM (accno) AS accno,
    TRIM (connaddress) AS connaddress, TRIM (CATEGORY)
    AS CATEGORY,
    TRIM (landmark) AS landmark,
    SUBSTR (accno, 1, 3) AS subdivisionname
    FROM scodetails
    WHERE LOWER (accno) LIKE
    LOWER ('%' || NVL (caccno, '#noval#') || '%')
    OR LOWER (NAME) LIKE LOWER ('%' || NVL (cname, '#noval#') || '%')
    OR LOWER (connaddress) LIKE
    LOWER ('%' || NVL (cadd, '#noval#') || '%')
    OR phone LIKE '%' || NVL (cphone, '#noval#') || '%'
    OR accno = (SELECT accno
    FROM requestregistration
    WHERE requestid = creqid);
    it's ok for small tables but now data increase .......
    searching method is very slow
    now i want to tune this query for better performance
    please sugg me best method
    Thanks in advance
    Regards
    vij..

    The link given by Asif should get you on the right track for tuning this query.
    I just formatted your SQL:
    SELECT Trim(NAME)        AS NAME,
           Trim(accno)       AS accno,
           Trim(connaddress) AS connaddress,
           Trim(category)    AS category,
           Trim(landmark)    AS landmark,
           Substr(accno,1,3) AS subdivisionname
    FROM   consumermaster
    WHERE  Lower(accno) LIKE Lower('%'
                                   ||Nvl(caccno,'#noval#')
                                   ||'%')
            OR Lower(NAME) LIKE Lower('%'
                                      ||Nvl(cname,'#noval#')
                                      ||'%')
            OR Lower(connaddress) LIKE Lower('%'
                                             ||Nvl(cadd,'#noval#')
                                             ||'%')
            OR phone LIKE '%'
                          ||Nvl(cphone,'#noval#')
                          ||'%'
            OR accno = (SELECT accno
                        FROM   requestregistration
                        WHERE  requestid = creqid)
    UNION
    SELECT Trim(NAME)        AS NAME,
           Trim(accno)       AS accno,
           Trim(connaddress) AS connaddress,
           Trim(category)    AS category,
           Trim(landmark)    AS landmark,
           Substr(accno,1,3) AS subdivisionname
    FROM   scodetails
    WHERE  Lower(accno) LIKE Lower('%'
                                   ||Nvl(caccno,'#noval#')
                                   ||'%')
            OR Lower(NAME) LIKE Lower('%'
                                      ||Nvl(cname,'#noval#')
                                      ||'%')
            OR Lower(connaddress) LIKE Lower('%'
                                             ||Nvl(cadd,'#noval#')
                                             ||'%')
            OR phone LIKE '%'
                          ||Nvl(cphone,'#noval#')
                          ||'%'
            OR accno = (SELECT accno
                        FROM   requestregistration
                        WHERE  requestid = creqid); You are using some function on almost each and every column in the where clause. Try getting rid of them as they are hindering the use of indexes, if any, on any of the columns.
    Also the guidelines in the link provided are the best starting point.

  • Need help for SQL Query last 5 mins Records.

    I need the data between the last five minutes from a table which contains Timeid Column and data type is date.
    select sysdate,(sysdate-((mod(extract(minutes from systimestamp),5)+5)/24/60)-((extract(second from systimestamp))/24/60/60)) Start_date,
    (sysdate-((mod(extract(minutes from systimestamp),5))/24/60)-((extract(second from systimestamp))/24/60/60)) End_Date;
    Suppose now the current time is 01:20:00PM then the output should be from
    Current Date & Time Start Date & Time End Date & Time
    10/18/2007 01:20:00 10/18/2007 01:10:01 10/18/2007 01:15:00
    Suppose now the current time is 01:20:01 then the output should be from
    Current Date & Time Start Date & Time End Date & Time
    10/18/2007 01:20:01 10/18/2007 01:15:01 10/18/2007 01:20:00
    The output i am getting where as i need the output shown above.
    Current Date & Time Start Date & Time End Date & Time
    10/18/2007 01:20:01 10/18/2007 01:14:59 10/18/2007 01:19:59

    SQL> select sysdate,
      2       sysdate -
      3           (decode(mod(to_number(to_char(sysdate,'sssss')),300),0,300,
      4            mod(to_number(to_char(sysdate,'sssss')),300))+300)/(24*60*60 )
      5                     st_time,
      6         sysdate -
      7           decode(mod(to_number(to_char(sysdate,'sssss')),300),0,300,
      8            mod(to_number(to_char(sysdate,'sssss')),300))/(24*60*60 )
      9                         end_time
    10  from dual;
    SYSDATE              ST_TIME              END_TIME
    18-oct-2007 16:39:46 18-oct-2007 16:30:00 18-oct-2007 16:35:00
    SQL> /
    SYSDATE              ST_TIME              END_TIME
    18-oct-2007 16:39:59 18-oct-2007 16:30:00 18-oct-2007 16:35:00
    SQL> /
    SYSDATE              ST_TIME              END_TIME
    18-oct-2007 16:40:00 18-oct-2007 16:30:00 18-oct-2007 16:35:00
    SQL> /
    SYSDATE              ST_TIME              END_TIME
    18-oct-2007 16:40:01 18-oct-2007 16:35:00 18-oct-2007 16:40:00                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Need help for SQL Query

    Hi Friends,
    I am using below query to genearet one report.
    {code}
    distinct a.plan_id,
    (SELECT external_plan_ref
    FROM bk9_t_plan
    WHERE plan_id = a.plan_id)
    "EXT_PAN_REF",
    (SELECT external_plan_ref
    FROM bk9_t_plan
    WHERE plan_id = b.depends_on_ba_plan_id)
    "EXT_PAN_REF1",
    (SELECT external_plan_ref
    FROM bk9_t_plan
    WHERE plan_id = c.drp_plan_id)
    "EXT_PAN_REF2",
    (SELECT external_plan_ref
    FROM bk9_t_plan
    WHERE plan_id = d.srp_plan_id)
    "EXT_PAN_REF3",
    (SELECT external_plan_ref
    FROM bk9_t_plan
    WHERE plan_id = e.DRP_TO_DRP_PLAN_ID)
    "EXT_PAN_REF4",
    (SELECT external_plan_ref
    FROM bk9_t_plan
    WHERE plan_id = f.srp_plan_id)
    "EXT_PAN_REF5"
    FROM BK9_T_BUSINESS_ACTIVITY a,
    BK9_T_BA_DEPENDENCY b,
    BK9_T_BA_DRP_DEP c,
    BK9_T_BA_SRP_DEP d,
    BK9_T_DRP_DEPENDENCY e,
    BK9_T_SYSTEM_DEPENDENCY f
    WHERE     a.plan_id = b.ba_to_ba_plan_id
    AND a.plan_id = c.ba_plan_id
    AND a.plan_id = d.ba_plan_id
    AND c.drp_plan_id = e.DRP_TO_DRP_PLAN_ID
    AND e.DRP_TO_DRP_PLAN_ID = f.drp_plan_id
    {code}
    My output is like this :
    {code}
    22767 19093 19095 19049  19049 19059
    22767 19093 19095 19049  19049 19060
    22767 19093 19095 19062  19062 19060
    22767 19093 19095 19062  19062 19061
    22768 19094 19093 19062  19062 19060
    22768 19094 19093 19062  19062 19061
    {code}
    But What i am looking is like this.
    {code}
    22767 19093 19095 19049  19049 19059
    22767                                               19060
    22767 19093 19095 19062  19062 19060
    22767                                              19061
    22768 19094 19093 19062 19062 19060
    22768                                              19061
    {code}
    Please help.

    Hi,
    Could you please illuminate our minds and spend a bit of time in explaining the logic? That will be much easier without reading the crystal ball which nobody has it here.
    Please read: Re: 2. How do I ask a question on the forums?
    And please provide sample data (create table and insert statement), description of the logic, database version and everything else which is specified in the FAQ
    Regards.
    Al

  • Need help with SQL Query with Inline View + Group by

    Hello Gurus,
    I would really appreciate your time and effort regarding this query. I have the following data set.
    Reference_No---Check_Number---Check_Date--------Description-------------------------------Invoice_Number----------Invoice_Type---Paid_Amount-----Vendor_Number
    1234567----------11223-------------- 7/5/2008----------paid for cleaning----------------------44345563------------------I-----------------*20.00*-------------19
    1234567----------11223--------------7/5/2008-----------Adjustment for bad quality---------44345563------------------A-----------------10.00------------19
    7654321----------11223--------------7/5/2008-----------Adjustment from last billing cycle-----23543556-------------------A--------------------50.00--------------19
    4653456----------11223--------------7/5/2008-----------paid for cleaning------------------------35654765--------------------I---------------------30.00-------------19
    Please Ignore '----', added it for clarity
    I am trying to write a query to aggregate paid_amount based on Reference_No, Check_Number, Payment_Date, Invoice_Number, Invoice_Type, Vendor_Number and display description with Invoice_type 'I' when there are multiple records with the same Reference_No, Check_Number, Payment_Date, Invoice_Number, Invoice_Type, Vendor_Number. When there are no multiple records I want to display the respective Description.
    The query should return the following data set
    Reference_No---Check_Number---Check_Date--------Description-------------------------------Invoice_Number----------Invoice_Type---Paid_Amount-----Vendor_Number
    1234567----------11223-------------- 7/5/2008----------paid for cleaning----------------------44345563------------------I-----------------*10.00*------------19
    7654321----------11223--------------7/5/2008-----------Adjustment from last billing cycle-----23543556-------------------A--------------------50.00--------------19
    4653456----------11223--------------7/5/2008-----------paid for cleaning------------------------35654765-------------------I---------------------30.00--------------19
    The following is my query. I am kind of lost.
    select B.Description, A.sequence_id,A.check_date, A.check_number, A.invoice_number, A.amount, A.vendor_number
    from (
    select sequence_id,check_date, check_number, invoice_number, sum(paid_amount) amount, vendor_number
    from INVOICE
    group by sequence_id,check_date, check_number, invoice_number, vendor_number
    ) A, INVOICE B
    where A.sequence_id = B.sequence_id
    Thanks,
    Nick

    It looks like it is a duplicate thread - correct me if i'm wrong in this case ->
    Need help with SQL Query with Inline View + Group by
    Regards.
    Satyaki De.

  • Need help regarding sql query

    hii All
    I need help for pl/sql function.
    I build a function for monthly attendance all employees.
    but now i want to show all Sundays with 'S' and others respectively 'P' and 'A'.
    Currently Sunday also shows 'A'
    So please help
    SQL queries ... like
    SELECT DISTINCT AL.USERNAME,
    CASE WHEN DAY1 =1 THEN 'P' ELSE 'A' END DAY1,
    CASE WHEN DAY2 =1 THEN 'P' ELSE 'A' END DAY2,
    CASE WHEN DAY3 =1 THEN 'P' ELSE 'A' END DAY3,
    CASE WHEN DAY31 =1 THEN 'P' ELSE 'A' END DAY31
    FROM
    SELECT DISTINCT USERNAME, SUM(CASE WHEN
    fromdt=TRUNC(L.LOGIN_DATE) THEN
    1
    ELSE
    0
    END) DAY1
    ,SUM(CASE WHEN
    fromdt +1=TRUNC(L.LOGIN_DATE) THEN
    1
    ELSE
    0
    END) DAY2,
    SUM(CASE WHEN
    fromdt+30=TRUNC(L.LOGIN_DATE) THEN
    1
    ELSE
    0
    END) DAY31
    FROM ( SELECT DISTINCT TRUNC(LOGIN_DATE)LOGIN_DATE ,USERNAME FROM FCDM_AUDIT_TRAIL_NEW WHERE
    TRUNC(LOGIN_DATE) BETWEEN fromdt AND todt
    -- to_date( login_date, 'dd-mom-yyyy') between to_date( fromdt, 'dd-mom-yyyy') and to_date( todt, 'dd-mom-yyyy')
    ) L
    GROUP BY USERNAME
    ) AL;
    how can i show matched Sundays and show with 'SUN' or 'S'
    Regards
    vij..

    Try this way:
    SELECT USERNAME,
           MAX(CASE WHEN to_char(fromdt,'d')='1' and fromdt=TRUNC(L.LOGIN_DATE) THEN 'S'
                    WHEN to_char(fromdt,'d')!='1' and fromdt=TRUNC(L.LOGIN_DATE) THEN 'P'
                    ELSE 'A') DAY1,
           MAX(CASE WHEN to_char(fromdt+1,'d')='1' and fromdt+1=TRUNC(L.LOGIN_DATE) THEN 'S'
                    WHEN to_char(fromdt+1,'d')!='1' and fromdt+1=TRUNC(L.LOGIN_DATE) THEN 'P'
                    ELSE 'A') DAY2,
           MAX(CASE WHEN to_char(fromdt+30,'d')='1' and fromdt+30=TRUNC(L.LOGIN_DATE) THEN 'S'
                    WHEN to_char(fromdt+30,'d')!='1' and fromdt+30=TRUNC(L.LOGIN_DATE) THEN 'P'
                    ELSE 'A') DAY31
    FROM
    (SELECT DISTINCT TRUNC(LOGIN_DATE) LOGIN_DATE,
            USERNAME
       FROM FCDM_AUDIT_TRAIL_NEW
      WHERE TRUNC(LOGIN_DATE) BETWEEN fromdt AND todt
    ) L
    Group by USERNAME
    ;Max
    http://oracleitalia.wordpress.com

  • I have problem with buying in games , I got the massage that the purchased can not be completed , please contact iTunes support.. I need help for my case please

    I have problem with buying in games , I got the massage that the purchased can not be completed , please contact iTunes support.. I need help for my case please

    http://www.apple.com/support/itunes/contact/

  • Need help for Format HD

    Hi I need Help for Formating HD so Wat Key need hold on start up for format HD I apprciated you Help

    Jesus:
    Formatting, Partitioning Erasing a Hard Disk Drive
    Warning! This procedure will destroy all data on your Hard Disk Drive. Be sure you have an up-to-date, tested backup of at least your Users folder and any third party applications you do not want to re-install before attempting this procedure.
    • With computer shut down insert install disk in optical drive.
    • Hit Power button and immediately after chime hold down the "C" key.
    • Select language
    • Go to the Utilities menu (Tiger) Installer menu (Panther & earlier) and launch Disk Utility.
    • Select your HDD (manufacturer ID) in left side bar.
    • Select Partition tab in main panel. (You are about to create a single partition volume.)
    • _Where available_ +Click on Options button+
    +• Select Apple Partition Map (PPC Macs) or GUID Partition Table (Intel Macs)+
    +• Click OK+
    • Select number of partitions in pull-down menu above Volume diagram.
    (Note 1: One partition is normally preferable for an internal HDD.)
    • Type in name in Name field (usually Macintosh HD)
    • Select Volume Format as Mac OS Extended (Journaled)
    • Click Partition button at bottom of panel.
    • Select Erase tab
    • Select the sub-volume (indented) under Manufacturer ID (usually Macintosh HD).
    • Check to be sure your Volume Name and Volume Format are correct.
    • Click Erase button
    • Quit Disk Utility.
    cornelius

  • Need help for my requirement...

    Need help for my requirement...
    Hello Experts,
    I have report where users can input the company, housebank, account ID and posting date.
    Now in one column of my report named 'Cash in Bank', I need to get all postings from cash
    accounts with GL code ending in '0'. Now, I know that I can get the amounts in BSIS/BSAS
    but how do I link it with the proper bank and account?
    For example:
                       Cash in Bank
    Bank A
      Account ID 1     1,000,000
      Account ID 2     25,000,000
    Hope you can help me guys. Thank you and take care!

    hi Viraylab,
    each house bank you can find in table T012, in T012K you'll find the bank accounts to the housebank, the G/L account will be in T012K-HKONT.
    hope this helps
    ec

  • Need help for flash builder

    i need help for flash builder 4 and papervison 3d. I need to create a slider with it ranges of value from 10 to 50 to adjust the camera values for the camera.fov and also need to create it for the yaw of the object from 0 to 360. I try to look for any slider event and classes in this program but cant find any, btw, i need to use the AS only project file.
    here is my codes:
    can you please tell me how i should modify the codes?
    package
        import flash.display.BitmapData;
        import flash.display.Sprite;
        import flash.events.Event;
        import org.papervision3d.materials.BitmapFileMaterial;
        import org.papervision3d.materials.BitmapMaterial;
        import org.papervision3d.objects.primitives.Sphere;
        import org.papervision3d.view.BasicView;
        [SWF (width="800", height="600", backgroundColor="0x000000",frameRate="30")]
        public class EarthBitmap extends BasicView
            private var sphere:Sphere;
            public function EarthBitmap()
                super(800 , 600);
                var earthmaterial:BitmapFileMaterial = new BitmapFileMaterial("../assets/Earth.jpg");
                sphere = new Sphere(earthmaterial,100,20,18);
                camera.fov = 25;
                scene.addChild(sphere);
                addEventListener(Event.ENTER_FRAME,rotateSphere);
            public function rotateSphere(evt:Event):void
                sphere.yaw(0.2);
                singleRender();

    Turn the click handler into a full on separate function. Then store all the views in an array and use Math.rand() to randomly choose one.
    Something like this:
    <fx:Script>
         <![CDATA[
              var questionsArray:Array = {question2,question3,question5,questionRed,questionGeography};
              function buttonClickHandler(event:MouseEvent){
                   var randomProblem:int = Math.floor(Math.random()*(questionsArray.length));     //generates a random integer between 0 and the total number of questions in the array (arrays are 0-based)
                   navigator.pushView(questionsArray[randomProblem]);
         ]]>
    </fx:Script>
    <s:Button id="randomProblemButton" label="Next Problem" click="buttonClickHandler(event)" />
    Haven't tested that, but something along that line should work

  • Need help for importing oracle 10G dump into 9i database

    hi, Someone help me to import oracle 10G dump into 9i database. I'm studying oracle . Im using oracle 10G developer suite(downloaded from oracle) and oracle 9i database. I saw some threads tat we can't import the higher version dumps into lower version database. But i'm badly need help for importing the dump...
    or
    someone please tell me the site to download oracle 9i Developer suite as i can't find it in oracle site...

    I didnt testet it to import a dump out of a 10g instance into a 9i instance if this export has been done using a 10g environment.
    But it is possible to perform an export with a 9i environment against a 10g instance.
    I am just testing this with a 9.2.0.8 environment against a 10.2.0.4.0 instance and is working so far.
    The system raises an EXP-00008 / ORA-37002 error after exporting the data segments (exporting post-schema procedural objects and actions).
    I am not sure if it is possible to perform an import to a 9i instance with this dump but maybe worth to give it a try.
    It should potentially be possible to export at least 9i compatible objects/segments with this approach.
    However, I have my doubts if this stunt is supported by oracle ...
    Message was edited by:
    user434854

  • Need Help for Nokia 6500 slide

    Hi all I'm A new Guy here ,
    But I do really need help for hard reset my phone
    I already try *#7073# But It doesn't work ,
    If Anybody know to make a hard reset please help

    rwss wrote:
    I'v got te same problem with my 6500 Slide, is there a button combination that we have to press
    to hard reset the 6500 Slide?!
    How does the 6500 slide hard reset?
    That's simple.
    All you have to do is:
    From MENU goto SETTINGS, When there scroll down and select 'Restore Factory Setting'.
    There are two options in there:
    "Restore Settings only"
    and
    "Restore all"
    Select "Restore All"
    When done the phone will delete every thing on the Phone memory(C:\)(contacts,picture,messages etc)
    and also restore phone to its original settings and will restart.
    This proceedure is mostly common on S40 phone.
    Hope this explain and solve the problem.

  • Need help for publishing web intelligence document (universe) into InfoView

    Post Author: mirage
    CA Forum: Publishing
    Hello all,
    I need help for publishing web intelligence document (universe) into InfoView.
    can't find this information in Business Objects Designer's Guide and in Business Objects Administrator Guide.
    Can somebody give short instructions how can I do it?
    Regards, Slava

    If the change between the 2 types of data has to happen dynamically during run time them
    1. Use 2 dataproviders
         a. Current
         b. Historic
    2. Merge the 2 dimensions
    3. Use Webi variable to switch between the measure of the current and historic universe
    Ex  if [year] < 2010 then historic.[expense] else current.[expense]
    Hope this helps,
    Divya

Maybe you are looking for

  • Is it Possible to Add a Power Pivot Gallery App in Office 365

    Hi, I had created a site collection by using Business Intelligence center Template in Office 365(E3 Subscription). But I am not able to see Power Pivot Gallery App to Add. I tried to find and activate any feature depends on this. But could not find a

  • Using project libraries for both web-based and AIR applications

    I need to develop substantial code to build both web-based and AIR applications.  Yes, they will have different features, especially when it comes to accessing files on the local file system. However, 98% of the code can be shared. I want to use a pr

  • Loading and parsing XML files

    I am currently working on an application in which I have a XML file that is 1.5 mb and has 1100 records that I need to load and parse. Loading takes less than a minute, but when I try to parse it with the DOM parser it's taking too much time. I am tr

  • Map quality in different iPads

    Just noticed that maps on my ipad 3 3G are very good definition in 2d and 3d especially in displaying London whereas on an ipad 2 wifi the maps are much lower definition and you can tell they are not the same map set from visible cars etc.  Both iPad

  • Scene Selection out of order...

    I made a movie in FInal Cut Pro and set up Scene Markers. They split up into scenes in iDVD, however the selection is out of order. I'm using 'Reflection White' theme. What happens is when you are selecting through the scenes on the menu it doesn't g