Cartesian Product from in-line queries

I have the following query:
SELECT AUDIT_MONTH, AUDITS, DEFECTS
FROM
select distinct(to_char(AUDIT_DATE,'MM/YY')) as AUDIT_MONTH
from v_safety_audit_records
select count(distinct(AUDIT_ID)) AUDITS
from v_safety_audit_records
group by to_char(AUDIT_DATE,'MM/YY')
select count(KEY_ID) DEFECTS
from v_safety_audit_records
where SUBAREA_ID NOT LIKE '_98'
and SUBAREA_ID NOT LIKE '_99'
group by to_char(AUDIT_DATE,'MM/YY')
but it keeps giving me a cartesian product. Is there a way to re-write this so that I only get the month, the number of audits, and number of defects on a line rather than number of months x number of months worth of lines? I can't seem to get the join conditions worked out... I can re-write this all using views, but as it is for a single report, I'd rather not bother with more views if I can avoid it.
Thanks in advance.

The problem is that the query doesn't return a single row and isn't meant to. I tried:
SELECT
select distinct(to_char(AUDIT_DATE,'MM/YY'))
from v_safety_audit_records
group by to_char(AUDIT_DATE,'MM/YY')
) AUDIT_MONTH,
select count(distinct(AUDIT_ID))
from v_safety_audit_records
group by to_char(AUDIT_DATE,'MM/YY')
) AUDITS,
select count(KEY_ID)
from v_safety_audit_records
where SUBAREA_ID NOT LIKE '_98'
and SUBAREA_ID NOT LIKE '_99'
group by to_char(AUDIT_DATE,'MM/YY')
) DEFECTS
FROM DUAL;
and got "ORA-01427: single-row subquery returns more than one row". It would be a good idea if I only needed it for one month, however.

Similar Messages

  • General algorithm for cartesian product

    i am looking for an algorithm to get the cartesian product from a set of sets like {{1,2,3,4},{a,b,c},{x,y,z,7,15}...} - this means in most general form.
    google yields no results :-(. i think implementing it by myself is not a good idea.

    dermoritz wrote:
    prometheuzz is your algorithm better than n*mi n: number of sets mi: cardinality of the set i ?
    can you short explain the algorithm?You can't do any better than that because for n sets: S(0), S(1), S(2) ... S(n-1) there are prod(i in [0, n), |S(i)|) elements of the caresian product. Prometeuzz algorithm generates
    one at ever pass of the loop executing n steps per element. If you're afraid that the product number will be too large you can also fiddle with the indexes themselves:
    // scard[i] == |S(i)|
    // prod[i] == element of S(i) in product
    int[] next(int[] scard, int[] prod) {
       for (int i= prod.lerngth; i-- > 0; prod= 0)
    if (++prod[i] < scard[i]) return prod; // return indexes of next product
    return null; // no next product anymore
    }kind regards,
    Jos                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Urgent plz help me out about cartesian product

    plz...its urgent,can anyone help in the following query where iam getting cartesian product,so how to get result without cartesian product
    this is the query
    SELECT DISTINCT MIS.segment1 "ITEM CODE",
    MIS.DESCRIPTION "DESCRIP"
    ,MIS.Primary_uom_code "UOM",
    MTL.LOT_NUMBER "LOT NUMBER"
    ,A.PARTY_NUMBER "CUSTOMER NUMBER",
    A.PARTY_NAME "CUSTOMER NAME",
    (A.ADDRESS1||A.ADDRESS2||A.ADDRESS3||A.ADDRESS4) "SHIP TO",
    B.DELIVERY_DETAIL_ID "DO NO",B.SHIPPED_QUANTITY "SHIPPED QUANTITY"
    ,C.ULTIMATE_DROPOFF_DATE "ISSUED DATE"
    ,D.ORDER_NUMBER "SALES ORDER NUMBER"
    ,E.LINE_NUMBER "SALES ORDER LINE"
    FROM MTL_SYSTEM_ITEMS MIS
    ,MTL_TRANSACTION_LOT_NUMBERS MTL
    ,HZ_PARTIES A,
    WSH_DELIVERY_DETAILS B,
    WSH_NEW_DELIVERIES C,
    OE_ORDER_HEADERS_ALL D,
    OE_ORDER_LINES_ALL E
    WHERE MIS.INVENTORY_ITEM_ID=MTL.INVENTORY_ITEM_ID
    AND B.INVENTORY_ITEM_ID=MIS.INVENTORY_ITEM_ID
    AND A.PARTY_ID=B.CUSTOMER_ID
    AND B.DELIVERY_DETAIL_ID=C.DELIVERY_ID
    AND MIS.INVENTORY_ITEM_ID=E.INVENTORY_ITEM_ID
    AND D.HEADER_ID=E.HEADER_ID

    A lot of times when I get duplicate results, I'll do a select * and see why. Often one of those tables will have a sequenced value that could repeat several times for a combination of values.
    If thats the case, you may need to add something like:
    ...and a.id = (select min(id)
                     from b
                    where a.col = b.col)

  • Cartesian Product in Select

        Hi all!
    I need help.
    I have this function that launches a Select. My Oracle Grid tells me, when I tune the Select of this function, that there is a Cartesian Product. I understand what a Cartesian Product is, but I fail to find it. Can you help me by pointing out WHERE is the misteke? Thank you!!
    P.s. Oracle EE 10.2.0.4 on windows Server 2003 R2 SP2 64Bit
    [code]
    create or replace
    FUNCTION          "ANA_GETVERBALE"
      v_VerbaleId      IN NUMBER DEFAULT NULL,
      v_Sezione        IN VARCHAR2 DEFAULT NULL,
      v_NumeroVerbale  IN VARCHAR2 DEFAULT NULL,
      v_DataVerbale    IN DATE DEFAULT NULL,
      v_TargaVeicolo   IN VARCHAR2 DEFAULT NULL,
      v_Serie          IN VARCHAR2 DEFAULT NULL,
      v_LoggedUser IN VARCHAR2 DEFAULT NULL
    RETURN SYS_REFCURSOR
    AS
       cv_1 SYS_REFCURSOR;
    BEGIN
      OPEN cv_1 FOR
        SELECT
          ANA_M.VerbaleId,
          ANA_M.Sezione,
          ANA_M.NumeroVerbale,
          ANA_M.DataVerbale,
          ANA_M.TargaVeicolo,
          ANA_M.Serie,
          SCH_C.StatoCartellinoId,
          LOV_StatoCartellino.ListOfValueName StatoCartellino,
          sch_c.cartellinoid
        FROM ANA_Materia_Verbale ANA_M
        INNER JOIN SCH_Cartellini SCH_C ON SCH_C.SoggettoId=ana_m.verbaleid AND SCH_C.TipoSoggettoId = SIS_CONSTANTS_PKG.VB
        INNER JOIN SIC_PROFILO_STATO SIC_PSC ON SIC_PSC.STATOID=SCH_C.STATOCARTELLINOID
        INNER JOIN SIC_PROFILI_USERS SIC_PUC ON SIC_PUC.PROFILOID=SIC_PSC.PROFILOID AND SIC_PUC.PERSONALID=v_LoggedUser
        LEFT JOIN TYP_ListOfValues LOV_StatoCartellino  ON LOV_StatoCartellino.ListOfValueId = SCH_C.StatoCartellinoId
        WHERE ( v_VerbaleId = SIS_CONSTANTS_PKG.AnyBigint OR ANA_M.VerbaleId = v_VerbaleId )
          AND ( v_Sezione = SIS_CONSTANTS_PKG.AnyString OR REGEXP_LIKE(ANA_M.Sezione, '^' || v_Sezione || '$', 'i') )
          AND ( v_serie = SIS_CONSTANTS_PKG.AnyString OR REGEXP_LIKE(ANA_M.Serie, '^' || v_Serie || '$', 'i') )
          AND ( v_NumeroVerbale = SIS_CONSTANTS_PKG.AnyString OR ANA_M.NumeroVerbale = v_NumeroVerbale )
          AND ( v_DataVerbale = SIS_CONSTANTS_PKG.AnyDateTime OR ANA_M.DataVerbale = v_DataVerbale )
          AND ( v_TargaVeicolo = SIS_CONSTANTS_PKG.AnyString OR REGEXP_LIKE(ANA_M.TargaVeicolo,'^' || v_TargaVeicolo || '$', 'i') );
      RETURN cv_1;
    END;
    [/code]

    ....ouch... well that explains a LOT!! The real problem was the Oracle Grid SQL_TUNING that warned me that the SELECT contained a CARTESIAN PRODUCT:
    Ristruttura SQL
    An expensive cartesian product operation was found at line ID 4 of the execution plan.
    Consider removing the disconnected table or view from this statement or add a join condition which refers to it.
    A cartesian product should be avoided whenever possible because it is an expensive operation and might produce a large amount of data.
    with this EXECUTION PLAN:
    Operazione
    ID riga
    Oggetto
    Object type
    Ordine
    Righe
    Dimensione (KB)
    Costo
    Tempo (sec)
    Costo CPU
    Costo I/O
    SELECT STATEMENT
    0
    13
    1
    0,091
    460
    6
    116.852.560
    452
    NESTED LOOPS OUTER
    1
    12
    1
    0,091
    460
    6
    116.852.560
    452
    NESTED LOOPS
    2
    9
    1
    0,079
    459
    6
    116.843.328
    451
    NESTED LOOPS
    3
    7
    2
    0,141
    457
    6
    116.826.984
    449
    MERGE JOIN CARTESIAN
    4
    4
    2
    0,102
    451
    6
    116.781.136
    443
    INDEX FAST FULL SCAN
    5
    DOCARK.PK_SIC_PROFILI_USERS
    INDEX (UNIQUE)
    1
    1
    0,010
    2
    1
    81.903
    2
    BUFFER SORT
    6
    3
    2
    0,082
    449
    6
    116.699.232
    441
    TABLE ACCESS FULL
    7
    DOCARK.ANA_MATERIA_VERBALE
    TABLE
    2
    2
    0,082
    449
    6
    116.699.232
    441
    TABLE ACCESS BY INDEX ROWID
    8
    DOCARK.SCH_CARTELLINI
    TABLE
    6
    1
    0,020
    3
    1
    22.924
    3
    INDEX RANGE SCAN
    9
    DOCARK.IDX_SCH_CARTELLINI_SOG_TIPO
    INDEX
    5
    1
    2
    1
    15.493
    2
    INDEX RANGE SCAN
    10
    DOCARK.PK_SIC_PROFILO_STATO
    INDEX (UNIQUE)
    8
    1
    0,009
    1
    1
    8.171
    1
    TABLE ACCESS BY INDEX ROWID
    11
    DOCARK.TYP_LISTOFVALUES
    TABLE
    11
    1
    0,012
    1
    1
    9.231
    1
    INDEX UNIQUE SCAN
    12
    DOCARK.PK_TYP_LISTOFVALUES
    INDEX (UNIQUE)
    10
    1
    0
    1
    1.900
    0
    So I started trying to REMOVE the Cartesian Product. But first I had to find it! So apparently I shouldn't worry too much...
    The real problem is that I have to work with funtions and DBs created by others, so I am not sure what to expect from most of the Functions. Apparently this execution is correct no matter what that the Tunig Advisor says!
    Thanks!

  • Joining DB VIEW and Command result in cartesian product

    hello,
    My SQL query is joining a DB view and a Command(=ad hoc query).
    Nonetheless from the results it appears that CR didn't join the views correctly, it returns a cartesian product.
    Any idea what the issue could be, I'm using very simple queries.
    Thanks in advance

    #1  make sure you are linking everything together properly in the "Links" tab of the Database Expert
    #2  In my experience, it's just a bad idea to join SQL commands and other tables.  I had poor performance issues in my case.  (It prevents server side filtering and grouping)  My suggestion is to write out the entire thing in the command.  If you are pulling from multiple database, write a separate command for each database and link them.

  • How to force Cartesian Product for unlineked (DBF) tables

    Hello
    We have been using CR8.5 for many years and we are just about to perform major upgrade to CR2011. I have, howverm found one strange behavior.
    Many of our reports are implemented in following way:
    MainTable.DBF (contains reported rows)
    ParamTable.DBF (contains one row with some general parameters)
    There is no data "link" between these tables but t makes sense to expect that every record from main table will see record from param table.
    in CR 8.5 Cartesian product of MainTable X ParamTable was ALWAYS available ad therefore we were able to (for example) hide the details & show only group totals, or display some header information (this can be also done by sub-report).
    in CR2011, however, this seems not to be the case anymore. Namely:
    any old report that I open in CR2011 has param line available only for the very first record and I was not able to find a way how to change it
    if I recreate the report from the scratch, sometimes Cartesian product is "provided" and sometimes not - I really do not know the reason for the decision.
    [I have one very ugly workaround: link these two tables with != (not equal operation) between two unrelated fields that can never be the same]
    Is there any "solution" to this cause as it blocks us from upgrading to the latest version?
    Kind Regards,
    Martin Fontan

    Hi Martin,
    Long story so here's the short one. As of CR 9 we completely redeveloped our database drivers and query engine. We removed all of the "hack" work arounds in our code for DB clients did not follow the rules, this forces the DB makers to fix the client engine and follow ANSII 92 standards. You also can no longer edit the SQL statement.
    We have also never supported unlinked tables, CR is a Relational database reporting tool. Us a subreport if you must use an unlinked table, or as you have discovered using a != type.
    Other work around is to use a Command, it' sin the Database wizard, write your own SQL, we simply pass it to the client. There is no option directly to set location from a Table to a SQL Command but search here, Brian Dong found a way around this limitation using a CR Wizard.
    Thanks
    Don

  • Getting cartesian product

    can anyone help in the following query where iam getting cartesian product,so how to get result without cartesian product
    this is the query
    SELECT DISTINCT MIS.segment1 "ITEM CODE",
    MIS.DESCRIPTION "DESCRIP"
    ,MIS.Primary_uom_code "UOM",
    MTL.LOT_NUMBER "LOT NUMBER"
    ,A.PARTY_NUMBER "CUSTOMER NUMBER",
    A.PARTY_NAME "CUSTOMER NAME",
    (A.ADDRESS1||A.ADDRESS2||A.ADDRESS3||A.ADDRESS4) "SHIP TO",
    B.DELIVERY_DETAIL_ID "DO NO",B.SHIPPED_QUANTITY "SHIPPED QUANTITY"
    ,C.ULTIMATE_DROPOFF_DATE "ISSUED DATE"
    ,D.ORDER_NUMBER "SALES ORDER NUMBER"
    ,E.LINE_NUMBER "SALES ORDER LINE"
    FROM MTL_SYSTEM_ITEMS MIS
    ,MTL_TRANSACTION_LOT_NUMBERS MTL
         ,HZ_PARTIES A,
         WSH_DELIVERY_DETAILS B,
         WSH_NEW_DELIVERIES C,
         OE_ORDER_HEADERS_ALL D,
         OE_ORDER_LINES_ALL E
    WHERE MIS.INVENTORY_ITEM_ID=MTL.INVENTORY_ITEM_ID
    AND B.INVENTORY_ITEM_ID=MIS.INVENTORY_ITEM_ID
    AND A.PARTY_ID=B.CUSTOMER_ID
    AND B.DELIVERY_DETAIL_ID=C.DELIVERY_ID
    AND MIS.INVENTORY_ITEM_ID=E.INVENTORY_ITEM_ID
    AND D.HEADER_ID=E.HEADER_ID

    SELECT DISTINCT MIS.segment1 "ITEM CODE",
                    MIS.DESCRIPTION "DESCRIP"
                    ,MIS.Primary_uom_code "UOM",
                    MTL.LOT_NUMBER "LOT NUMBER"
                    ,A.PARTY_NUMBER "CUSTOMER NUMBER",
                    A.PARTY_NAME "CUSTOMER NAME",
                    (A.ADDRESS1||A.ADDRESS2||A.ADDRESS3||A.ADDRESS4) "SHIP TO",
                    B.DELIVERY_DETAIL_ID "DO NO",B.SHIPPED_QUANTITY "SHIPPED QUANTITY"
                    ,C.ULTIMATE_DROPOFF_DATE "ISSUED DATE"
                    ,D.ORDER_NUMBER "SALES ORDER NUMBER"
                    ,E.LINE_NUMBER "SALES ORDER LINE"
      FROM          MTL_SYSTEM_ITEMS             MIS,
                    MTL_TRANSACTION_LOT_NUMBERS  MTL,
                    HZ_PARTIES                   A,
                    WSH_DELIVERY_DETAILS         B,
                    WSH_NEW_DELIVERIES           C,
                    OE_ORDER_HEADERS_ALL         D,
                    OE_ORDER_LINES_ALL           E
    WHERE          MIS.INVENTORY_ITEM_ID = MTL.INVENTORY_ITEM_ID
       AND          MIS.INVENTORY_ITEM_ID = E.INVENTORY_ITEM_ID
       AND          B.INVENTORY_ITEM_ID   = MIS.INVENTORY_ITEM_ID
       AND          A.PARTY_ID            = B.CUSTOMER_ID
       AND          B.DELIVERY_DETAIL_ID  = C.DELIVERY_ID
    AND C........ = D. .......
       AND          D.HEADER_ID           = E.HEADER_ID
    ;I am not sure but I guess a relationship (in bold) is missing.
    HTH
    Ghulam

  • CARTESIAN PRODUCT problem

    hello,
    i m trying to find the difference for calculating the DIFFENCE IN STOCK FOR OPC,PPC,CLINKER BY USING FOLLOWING SQL-QUERY
    SELECT TO_CHAR(a.dateofmtrl,'YYYY') YEAR,
    SUM(a.rm1) - SUM(b.rm1) - SUM(c.rm1) OPC,
    SUM(a.rm2) - SUM(b.rm2) - sum(c.rm2) PPC,
    SUM(a.rm3) - SUM(b.rm3) - sum(c.rm3) CLINKER
    FROM rawmtrl_graph a
    INNER JOIN rawmtrl_graph b ON TO_CHAR(a.dateofmtrl,'YYYY') =TO_CHAR(B.dateofmtrl,'YYYY')
    INNER JOIN rawmtrl_graph c ON TO_CHAR(a.dateofmtrl,'YYYY') =TO_CHAR(C.dateofmtrl,'YYYY')
    WHERE a.mtrl_flag='P'
    AND b.mtrl_flag='D'
    AND c.mtrl_flag='CS'
    GROUP BY TO_CHAR(a.dateofmtrl,'YYYY')
    BUT IT IS GIVING CARTESIAN PRODUCT...
    HOW TO MODIFY THE QUERY FOR FINDING EXACT FIGURE??????
    THANKS IN ADVENCE FOR ANY HELP.....

    Hi,
    please always put your code between two lines starting with {noformat}{noformat}.
    Additionally when you put insert statement put them entirely and not copying from one table we don't have.
    Here the way to get the result you want:SELECT EXTRACT(YEAR FROM dateofmtrl) yr
    , SUM(CASE mtrl_flag WHEN 'P' THEN rm1 ELSE -rm1 END) AS opc
    , SUM(CASE mtrl_flag WHEN 'P' THEN rm2 ELSE -rm2 END) AS ppc
    , SUM(CASE mtrl_flag WHEN 'P' THEN rm3 ELSE -rm3 END) AS clinker
    FROM rawmtrlgraph
    GROUP BY EXTRACT(YEAR FROM dateofmtrl);
    YR OPC PPC CLINKER
    2011 50 54 55
    2012 -49 -3 -11
    Regards.
    Al                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • I can not uninstall Office 2013 from command line

    Hi, I have been stuck for a while trying to uninstall Office 2013 via command line. Installation file was downloaded from Volume Licensing Service Center, Uninstall.xml file for silent uninstallation looks like this:
    <Configuration Product=”ProPlus”>
    <Display Level=”basic” CompletionNotice=”yes” SuppressModal=”yes” AcceptEula=”yes” />
    </Configuration>
    From command line the following will not work:
    setup /uninstall ProPlus /config .\ProPlus.ww\Uninstall.xml
    Error: Setup can not find or validate an installation file. Please try reinstalling Office . . .
    setup /uninstall ProPlus gives me GUI to continue process - it seems /config .\ProPlus.ww\Uninstall.xml part does not work as it should be
    This is very important to me since I used above command line in SCCM 2012 R2 to allow user to uninstall Office 2013 by itself via Software Center. When this failed I tried locally but the error was the same. This should have been trivial task - silent uninstallation
    using .xml file. It is not a rocket science. I am very angry because losing time for something like this is unacceptable for system engineers working with SCCM 2012 R2.

    Hi,
    This error might occurs due to lots of reasons. Where is the installation file stored? If it's stored on a network share, please copy it to your local disk, and then manually run the command again. This way, we'll see if the installation file is the
    problem.
    If issue persists in this case, then this generally means that something wrong with the installation file. Please try to redownload it and then try again.
    Please also make sure that you're executing the command with elevated privileges (run as administrator).
    Regards,
    Ethan Hua
    Forum Support
    Come back and mark the replies as answers if they help and unmark them if they provide no help.
    If you have any feedback on our support, please click
    here

  • Best performance in a cartesian product

    i've got a select that needs a cartesian product.
    ex:
    SELECT NVL(a.year,cp.year) year, NVL(a.month,cp.month), NVL(a.value,0) value
    FROM
    (select year, month from year, month) cp, values a
    WHERE cp.year = a.year(+) AND cp.month = a.month(+)
    i have to show all records possible even if they don't have any values on the table.
    In the beginning with fewer values, it ran OK.... but now with a lot more it begins to take a little longer (about 10 times longer).
    What is the best way to improve this kind of selects???
    Thank you.

    Best Case :
    No one shold be in red color in analysis is the best runtime.
    All should be in Green.
    or
    OK Case :
    Database level - Red is not acceptable
    ABAP Level - Red can be accepted and can be a good runtime.
    System Level - Red is not acceptable.
    Worst Case:
    All are in Red Color

  • Query resulting in cartesian product-plz help

    select count(distinct e.hiredate),count(distinct b.hiredate) from scott.emp e, scott.emp b where e.hiredate<to_date('01-DEC-80','DD-MON-YY') and b.hiredate<to_date('23-JUN-81','DD-MON-YY')

    Hi,
    When I query it individually its giving me as below and its correct.
    SQL> select count(hiredate) from scott.emp where hiredate<'01-DEC-81';
    COUNT(HIREDATE)
    9
    SQL> select count(hiredate) from scott.emp where hiredate<'23-JUN-81';
    COUNT(HIREDATE)
    6
    Now I want these two merged in same query and it should give me the same result
    SQL> select count(distinct e.hiredate),count(distinct b.hiredate) from scott.emp
    e, scott.emp b where e.hiredate<'01-DEC-80' and b.hiredate<'23-JUN-81';
    COUNT(DISTINCTE.HIREDATE) COUNT(DISTINCTB.HIREDATE)
    0 0
    But its giving me either cartesian product or the result above.
    I have already used logical operator AND .

  • How to restore or backup Apex application from Command line ? URGENT

    We have Oracle apex 4.1 installed in Oracle 11g R2 database (windows 64-bit) 2008 R2
    For some reason our database dictionary objects are corrupted.
    We wanted to backup our Apex applications in some workspaces ASAP.
    We are not able to access apex from http://localhost:7777/pls/apex/htmldb_login
    We have an underlying database schema export (expdp).
    1) Is there a way to export or backup the apex application without logging into the apex URL ? if yes how ?
    2) Does Oracle has any of its own native tool to backup and restore from command line ?
    Thanks in advance

    My (MS Windows) experience, if I may; perhaps you'll find something useful.
    You'll find the README.TXT file in /apex/utilities directory. Read it.
    In order to use APEXExport, you need JDK version 1.5 or higher. Check your version by typing (and viewing the result):
    C:\>java –version
    java version "1.6.0_06"
    Java(TM) SE Runtime Environment (build 1.6.0_06-b02)
    Java HotSpot(TM) Client VM (build 10.0-b22, mixed mode, sharing)Its directory should be part of the PATH environment variable: on my computer, directory name isC:\Program Files\Java\jre1.6.0_06\binFurthermore, Oracle JDBC class libraries must be part of the CLASSPATH environment variable. Check whether it exists (in Control Panel - System - Advanced - Environment Variables). For my 10gXE, it is here:C:\oraclexe\app\oracle\product\10.2.0\server\jdbc\lib\ojdbc14.jarI couldn't make it work; didn't know that ".\" directory must be entered into CLASSPATH as well (found that information in Arie Geller's book). Therefore, my final CLASSPATH version is:.\;C:\oraclexe\app\oracle\product\10.2.0\server\jdbc\lib\ojdbc14.jarOK, setup is done. Now, go to your /apex/utilities directory and, from the command prompt, run (mind the upper case!)java oracle.apex.APEXExportwhich will show a short help.
    I chose to export the whole workspace. In order to do that, I need the workspace ID (got it from Apex's SQL Workshop; that might be a problem as you can't get there, can you? I can't tell how to find that information apart from SQL Workshop, but I'm pretty sure someone, who is much more experienced than me, will know it). OK, here's how you find it:select v('WORKSPACE_ID') from dual;Finally, here's the final step - export:C:\apex\utilities>java oracle.apex.APEXExport -db localhost:1521:xe -user scott -password tiger -workspaceid 1038408092496568The result are fxxx.sql files (where "xxx" represents application number).
    I hope you'll manage to export your applications; basically, nothing special here (except that ".\" directory in the CLASSPATH variable).
    Best of luck!

  • Query to get the difference between 2 totals from 2 different queries

    I wanted to know if it is possible to get the difference between 2 totals from 2 different queries. I would explain with an example:
    1st query  - Select sum(homepass) from table 1
    2nd query – select sum(homepass) from table2
    Is it possible to display the difference like-
    Select sum(homepass) from table 1 - sum(homepass) from table2
    I know the above query would gives syntax error but is there a better way or a trick to get the above task accomplished from a single query.
    I hope, my question is clear.
    Please revert with the reply to my query.
    Regards

    tomernitin wrote:
    Try this one also:
    WITH adtn1
    AS
    SELECT 110 val1 FROM dual UNION ALL
    SELECT 100 FROM dual UNION ALL
    SELECT 90  FROM dual UNION ALL
    SELECT 10 FROM dual
    adtn2
    AS
    SELECT 10 val2 FROM dual UNION ALL
    SELECT 20 FROM dual UNION ALL
    SELECT 30  FROM dual UNION ALL
    SELECT 100 FROM dual
    SELECT(Sum(a1.val1)-Sum(a2.val2)) Diff FROM adtn1 a1,adtn2 a2;
    let me know if you still have any doubt.
    Um.... I don't think so. Not with the cartesian join between a1 and 2.

  • Query having cartesian product

    hi
    i have the following query
    select f.item_number, case when f.item_number='1020101002' then f.calc_cement_sk else f.calc_amount end act
                from XXNP_OPN_JOBLOG_EST_002 F WHERE f.OPN_JOBLOG_001_ID ='6369'
    output
    ITEM_NUMBER     ACT
    1020101001     NULL
    1020111001     NULL
    1020112001     NULL
    1020113004     NULL
    1020101002     494
    1020102007     232
    1020103004     37
    1020104004     557
    1020106002     20896
    1020111001     5
    1020112005     16253
    1020112008     46
    1020113004     40
    1020222010     1393
    ie 14 rows
    another query
    SELECT J.ITEM_NUMBER,j.opn_value  FROM XXNP_OPN_JOBLOG_RES_005 J  WHERE  J.OPN_JOBLOG_001_ID ='6369' 
    output
    ITEM_NUMBER     OPN_VALUE
    1010101003     1
    1010101004     3
    1010101005     2
    1010104016     1
    1010103001     76
    1010103002     228
    1010106001     2
    1010106006     147
    1010107010     1
    1010109009     1
    1010107015     866
    1010107014     799
    1010107016     1631
    ie 13 rows
    when i do
    select f.item_number, case when f.item_number='1020101002' then f.calc_cement_sk else f.calc_amount end act ,j.opn_value
           from XXNP_OPN_JOBLOG_EST_002 F ,XXNP_OPN_JOBLOG_RES_005 J   where   f.OPN_JOBLOG_001_ID = J.OPN_JOBLOG_001_ID and f.OPN_JOBLOG_001_ID ='6369'
    i get 182 rows :( i know its due to cartesian product
    is there any way i can get 27 rows  only ,can i get the output in the format given below
    ITEM_NUMBER     ACT                  opn_value
    1020101001     NULL
    1020111001     NULL
    1020112001     NULL
    1020113004     NULL
    1020101002     494
    1020102007     232
    1020103004     37
    1020104004     557
    1020106002     20896
    1020111001     5
    1020112005     16253
    1020112008     46
    1020113004     40
    1020222010     1393
    1010101003                                                                     1                                                    
    1010101004                                                                     3                                                              
    1010101005                                                                      2
    1010104016                                                                      1
    1010103001                                                                     76
    1010103002                                                                      228
    1010106001                                                                      2
    1010106006                                                                     147
    1010107010                                                                      1
    1010109009                                                                        1
    1010107015                                                                      866
    1010107014                                                                      791
    1010107016                                                                    1631kindly guide
    thanking in advance
    Edited by: makdutakdu on Mar 31, 2011 8:03 AM

    hi
    script for XXNP_OPN_JOBLOG_RES_005
    CREATE TABLE XXNP_OPN_JOBLOG_RES_005
      OPN_JOBLOG_005_ID  NUMBER,
      OPN_JOBLOG_001_ID  NUMBER,
      WIP_ENTITY_ID      NUMBER,
      WIP_ENTITY_NAME    VARCHAR2(240 BYTE),
      OPN_RESOURCE_CODE  VARCHAR2(30 BYTE),
      OPN_UOM_CODE       VARCHAR2(30 BYTE),
      OPN_VALUE          NUMBER,
      OPN_MOV_DATE       DATE,
      ORG_ID             NUMBER(15),
      CREATION_DATE      DATE,
      CREATED_BY         NUMBER(15),
      LAST_UPDATE_DATE   DATE,
      LAST_UPDATED_BY    NUMBER(15),
      LAST_UPDATE_LOGIN  NUMBER(15),
      OPN_RESOURCE_DESC  VARCHAR2(500 BYTE),
      ITEM_PRICE         NUMBER,
      ITEM_NUMBER        NUMBER(10),
      DIS_PER            NUMBER(3),
      EST_VALUE          NUMBER(15,3),
      VAL_ESTAB          NUMBER(15,3)
    script for XXNP_OPN_JOBLOG_EST_002
    CREATE TABLE XXNP_OPN_JOBLOG_EST_002
      OPN_JOBLOG_002_ID   NUMBER,
      OPN_JOBLOG_007_ID   NUMBER,
      INVENTORY_ITEM_ID   NUMBER,
      ITEM_NUMBER         VARCHAR2(20 BYTE),
      ITEM_NAME           VARCHAR2(40 BYTE),
      ITEM_UOM            VARCHAR2(30 BYTE),
      ITEM_VALUE          NUMBER,
      ITEM_PERCENT        NUMBER,
      OPN_AMOUNT          NUMBER,
      ITEM_CEMENT_SK      NUMBER,
      ORG_ID              NUMBER(15),
      CREATION_DATE       DATE,
      CREATED_BY          NUMBER(15),
      LAST_UPDATE_DATE    DATE,
      LAST_UPDATED_BY     NUMBER(15),
      LAST_UPDATE_LOGIN   NUMBER(15),
      OPN_JOBLOG_001_ID   NUMBER,
      OPN_JOBLOG_006_ID   NUMBER,
      ITEM_REF            NUMBER,
      DESCRIPTION         VARCHAR2(500 BYTE),
      CALC_AMOUNT         NUMBER,
      CALC_CEMENT_SK      NUMBER,
      )

  • Avoiding Cartesian Products

    Hi All
    I have an SQL query that is taking a long time to run or will crash due the structure.
    I'm querying 20 fields that are sourced from 4 tables.
    Usng SQL developer, I'm given the info that the query creates 3 or 4 cartesian products.
    The basic structure is as follows, EXAMPLE ONLY;
    SELECT CUSTOMERS, PLACE, VALUE, DDATE, PHONE_NUMBER
    FROM CUSTOMERS C, PLACE P, VALUE V, DDATE D, PHONE DETAILS N
    WHERE C.ADDRESS = P.ADDRESS
    AND D.DATE BETWEEN TO_DATE ('08/06/09' , 'DD/MM/YY')
    AND TO_DATE ('10/06/09' , 'DD/MM/YY')
    OR N.PHONE_DETAILS = C.PHONE_NUMBER
    I need to rewrite this to run more quickly & may have to completely change the query structure.
    If anyone has had the same issue & a fix I'd appreciate it. Thanks

    Hi Sanjay
    here's the query
    SELECT DISTINCT DECODE(SOURCE_SYSTEM, 'S', CONCAT('SR ', SR_NUMBER), SR_NUMBER) AS S.SR_NUMBER, S.SOURCE_SYSTEM, S.SR_AREA, S.SR_SUB_AREA, S.SR_STATUS, S.SR_SUB_STATUS, S.SR_CLOSED_DATE, S.SR_PRODUCT1, S.SR_PRODUCT2,S.SR_OWNER, S.SR_SERVICE_ID, S.SR_REASON1, S.SR_REASON2, S.SR_TIO_PRIORITY, S.SR_REF_NUMBER, S.SR_REF_NUMBER_TYPE, S.SR_DATE_RECD, S.SR_CIDN, S.SR_BUS_UNIT, S.SR_MBM_SEG, S.SR_BILL_ACCT_NUMBER, S.LATEST_UPDATE, C.BEFORE_CLEANSING, C.AFTER_CLEANSING, P.DEALING, P.SERVICE_ID, P.PDATE, P.DISPUTED_AMOUNT, P.ISSUE_1, P.ISSUE_2, P.ISSUE_3
    FROM SR_MERGED_DATA S, PL2_WE_050609 P, CLEANSED_TIO_REF_IDS C, PL2_UNLOC_090609 L
    WHERE S.SR_AREA = 'Issues'
    AND (L.PSR_NUMBER = S.SR_NUMBER)
    OR (P.SERVICE_ID = S.SR_SERVICE_ID
    AND SR_DATE_RECD BETWEEN TO_DATE('01/05/09','DD/MM/YY')
    AND TO_DATE('09/06/09', 'DD/MM/YY'))
    I think you may have answered my question.
    Should I try the same syntax as you have written it instead?

Maybe you are looking for

  • In FormView Pager Template shown in design page but not shown in runtime.....

    //////////////////////MY TABLE////////////////// USE [logistics_tab] GO /****** Object:  Table [dbo].[dtype]    Script Date: 02/07/2015 10:19:00 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO SET ANSI_PADDING ON GO CREATE TABLE [dbo].[dtype

  • Embed movie controls

    I have a Flash site that imports HTML copy from external text files. On one of the pages, I would like to list some clickable links to show some video clips. How do I get the swf to know that a certain link should start playing a movie clip, and disp

  • Pre-insert block level, Seq.Nextval leaving gaps problem

    Hi...form friends, I used DB sequence in pre-insert block level trigger. SELECT seq1.nextval INTO :abc.log_id FROM dual; Everything works fine,except leaving gaps randomly . It leaves around 10 no.s gaps in-between. And that happens randomly... lets

  • Connecting 7100G to Windows XP

    Hi, I have a user with a 7100G.  When connecting to Desktop Manager no connection is found.  However, when using the Device Manager, the USB connection is reported as valid and the PIN number shows. Desktop manager is V4.5, no other changes have been

  • A CS student. Drooling for macBook

    Im a CS student... is macbook ok with me? i'll be doing a lot of programming. Like C , C++, Assembly, Unix, Java, Vb.. you get the picture. thanks.. cant find any thread regarding this. good day!!! btw, im currently using pc..