Help with a PowerPivot query

Hi,
I've got a server audit log in PowerPivot (114,000 rows) which I provide some basic reporting from (PowerPivot is not my specialist subject so go easy).  What I now need to perform a Distinct filter, but can't get the logic right. Basically the log
as two bits of information, 1) is the source of the job and 2) if it was a success or failure.    What I need to do is to find all of the Source items that have never completed sucessfully.  Any ideas on what formula is best to use, or
do I need to split in to multiple sheets and create a table relationship?
Source,Status
======,======
Source1,Fail
Source1,Fail
Source1,Success
Source2,Fail
Source3,Fail
Source3,Success
So in the above example, I would only expect the filter to show me Source2
Thanks
Alex

Hi Alex,
using Power Query instead, it would work like this:
Once you've pushed your table to PQ, add a column "helper" with value=1.
Then pivot on "Status", taking "helper"-column into "values column"
(hope translation is understandable, as I'm using localized Version & translation via "Quick info" isn't working in the PQ menu)
Then filter on column "Success" = blank.
Imke

Similar Messages

  • Need some help with the Select query.

    Need some help with the Select query.
    I had created a Z table with the following fields :
    ZADS :
    MANDT
    VKORG
    ABGRU.
    I had written a select query as below :
    select single vkorg abgru from ZADS into it_rej.
    IT_REJ is a Work area:
    DATA : BEGIN OF IT_REJ,
            VKORG TYPE VBAK-VKORG,
            ABGRU TYPE VBAP-ABGRU,
           END OF IT_REJ.
    This is causing performance issue. They are asking me to include the where condition for this select query.
    What should be my select query here?
    Please suggest....
    Any suggestion will be apprecaiated!
    Regards,
    Developer

    Hello Everybody!
    Thank you for all your response!
    I had changes this work area into Internal table and changed the select query. PLease let me know if this causes any performance issues?
    I had created a Z table with the following fields :
    ZADS :
    MANDT
    VKORG
    ABGRU.
    I had written a select query as below :
    I had removed the select single and insted of using the Structure it_rej, I had changed it into Internal table 
    select vkorg abgru from ZADS into it_rej.
    Earlier :
    IT_REJ is a Work area:
    DATA : BEGIN OF IT_REJ,
    VKORG TYPE VBAK-VKORG,
    ABGRU TYPE VBAP-ABGRU,
    END OF IT_REJ.
    Now :
    DATA : BEGIN OF IT_REJ occurs 0,
    VKORG TYPE VBAK-VKORG,
    ABGRU TYPE VBAP-ABGRU,
    END OF IT_REJ.
    I guess this will fix the issue correct?
    PLease suggest!
    Regards,
    Developer.

  • Help with an SQL Query on the Logger

    We are running UCCE 8.5(3) and need help with an SQL query. When I run the below I would also like to see skill group information(name preferably)? Any help would be greatly appreciated!
    select * from dbo.t_Termination_Call_Detail where DateTime between '10-11-2012 00:00:00:00' and
    '10-11-2012 23:59:59:59'

    David, thanks for replying.  Unfortunitly I don't know enough about SQL to put that into a query and have it return data.  Would you be able to give an example on what the query would look like?

  • Help with Inner Join query in SQL

    Hope someone can help with this, as this is quite an involved project for me, and I'm just about there with it.
    My table structure is :
    table_packages
    packageID
    package
    packageDetails
    etc
    table_destinations
    destinationID
    destination
    destinationDetails
    etc
    table_packagedestinations
    packageID
    destinationID
    ..so nothing that complicated.
    So the idea is that I can have a package details page which shows the details of the package, along any destinations linked to that package via the packagedestinations table.
    So this is the last part really - to get the page to display the destinations, but I'm missing something along the way....
    This is the PHP from the header, including my INNER JOIN query....
    PHP Code:
    <?php
    $ParampackageID_WADApackages = "-1";
    if (isset($_GET['packageID'])) {
      $ParampackageID_WADApackages = (get_magic_quotes_gpc()) ? $_GET['packageID'] : addslashes($_GET['packageID']);
    $ParamSessionpackageID_WADApackages = "-1";
    if (isset($_SESSION['WADA_Insert_packages'])) {
      $ParamSessionpackageID_WADApackages = (get_magic_quotes_gpc()) ? $_SESSION['WADA_Insert_packages'] : addslashes($_SESSION['WADA_Insert_packages']);
    $ParampackageID2_WADApackages = "-1";
    if (isset($_GET['packageID'])) {
      $ParampackageID2_WADApackages = (get_magic_quotes_gpc()) ? $_GET['packageID'] : addslashes($_GET['packageID']);
    mysql_select_db($database_connPackages, $connPackages);
    $query_WADApackages = sprintf("SELECT packageID, package, costperpax, duration, baselocation, category, dateadded, agerange, hotel, educational_tours, field_trips, corporate_outings, plant_visits, budget_package, rollingtours, teambuilding, description, offer FROM packages WHERE packageID = %s OR ( -1= %s AND packageID= %s)", GetSQLValueString($ParampackageID_WADApackages, "int"),GetSQLValueString($ParampackageID2_WADApackages, "int"),GetSQLValueString($ParamSessionpackageID_WADApackages, "int"));
    $WADApackages = mysql_query($query_WADApackages, $connPackages) or die(mysql_error());
    $row_WADApackages = mysql_fetch_assoc($WADApackages);
    $totalRows_WADApackages = mysql_num_rows($WADApackages);
    $colname_educationalDestinations = "1";
    if (isset($_GET['PackageID'])) {
      $colname_educationalDestinations = (get_magic_quotes_gpc()) ? packageID : addslashes(packageID);
    mysql_select_db($database_connPackages, $connPackages);
    $query_educationalDestinations = sprintf("SELECT * FROM destinations INNER JOIN (packages INNER JOIN packagedestinations ON packages.packageID = packagedestinations.packageID) ON destinations.destinationID = packagedestinations.destinationID WHERE packages.packageID = %s ORDER BY destination ASC", GetSQLValueString($colname_educationalDestinations, "int"));
    $educationalDestinations = mysql_query($query_educationalDestinations, $connPackages) or die(mysql_error());
    $row_educationalDestinations = mysql_fetch_assoc($educationalDestinations);
    $totalRows_educationalDestinations = mysql_num_rows($educationalDestinations);
    ?>
    And where I'm trying to display the destinations themselves, I have : 
    <table>
            <tr>
                     <td>Destinations :</td>
                </tr>
               <?php do { ?>
            <tr>
                 <td><?php echo $row_educationalDestinations['destination']; ?></td>
            </tr>
            <?php } while ($row_educationalDestinations = mysql_fetch_assoc($educationalDestinations)); ?>
    </table>
    If anyone could have a quick look and help me out that would be much appreciated - not sure if its my SQL at the top, or the PHP in the page, but either way it would be good to get it working. 
    Thanks.

    First off, you need to get the database tables so that there is a relationship between them.
    In fact, if there is a one to one relationship, then it may be better to store all of your information in one table such as
    table_packages
    packageID
    package
    packageDetails
    destination
    destinationDetails
    etc
    If there is a one to many relationship, then the following would be true
    packages
    packageID
    package
    packageDetails
    etc
    destinations
    destinationID
    packageID
    destination
    destinationDetails
    etc
    The above assumes that there are many destinations to one package with the relationship coloured orange.
    Once you have the above correct you can apply your query as follows
    SELECT *
    FROM packages
    INNER JOIN destinations
    ON packages.packageID = destinations.packageID
    WHERE packages.packageID = %s
    ORDER BY destination ASC
    The above query will show all packages with relevant destinations

  • Need help with LikeFilter for querying the keyset instead of value

    Hi,
    I'm looking for help with the LikeFilter.
    I need to query the cache to get all entries with key starting with a particular string.
    I could see samples using LikeFilter for querying the values in the cache but not the keyset.
    Can someone help?
    E.g:
    Cache Entries:
    abc123 - value1
    abc234 - value2
    bcd123 - value3
    I want to get all entries with key starting with 'abc'.
    thanks,
    rama.

    NJ, thanks for the quick reply.
    I tried something similar (as below) but this code gives me 'java.lang.NoClassDefFoundError: com/tangosol/util/ValueExtractor'.
    KeyExtractor extractor = new KeyExtractor("getKey");
    Filter filter = new LikeFilter(extractor, id+":%",'-',false);
    -rama.
    Edited by: 911950 on Feb 2, 2012 1:18 PM

  • Help with a group query

    I have the following table
    EX_ID
    EX_NAME
    EX_SURNAME
    EX_FLAG
    1
    TOM
    JONES
    Y
    1
    JIM
    SLIM
    N
    1
    BO
    SELECTA
    Y
    2
    AIRES
    BEARS
    N
    2
    JIM
    DAVIES
    Y
    3
    PAUL
    BALL
    N
    3
    YOU
    KNOW
    N
    I need to create a query that only displays one of the ex_id’s, it doesn’t matter which one.  When the query has been run it will look like below:
    EX_ID
    EX_NAME
    EX_SURNAME
    EX_FLAG
    1
    TOM
    JONES
    Y
    2
    AIRES
    BEARS
    N
    3
    YOU
    KNOW
    N
    Can anyone help with this query?

    SELECT * FROM
    SELECT *,ROW_NUMBER () OVER (PARTITION BY ex_id ORDER BY (SELECT 0))
    FROM tbl
    ) AS Der WHERE rn=1
    Best Regards,Uri Dimant SQL Server MVP,
    http://sqlblog.com/blogs/uri_dimant/
    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting:
    Large scale of database and data cleansing
    Remote DBA Services:
    Improves MS SQL Database Performance
    SQL Server Integration Services:
    Business Intelligence

  • I need help with a SELECT query - help!

    Hello, I need help with a select statement.
    I have a table with 2 fields as shown below
    Name | Type
    John | 1
    John | 2
    John | 3
    Paul | 1
    Paul | 2
    Paul | 3
    Mark | 1
    Mark | 2
    I need a query that returns everything where the name has type 1 or 2 but not type 3. So in the example above the qery should bring back all the "Mark" records.
    Thanks,
    Ian

    Or, if the types are sequential from 1 upwards you could simply do:-
    SQL> create table t as
      2  select 'John' as name, 1 as type from dual union
      3  select 'John',2 from dual union
      4  select 'John',3 from dual union
      5  select 'Paul',1 from dual union
      6  select 'Paul',2 from dual union
      7  select 'Paul',3 from dual union
      8  select 'Paul',4 from dual union
      9  select 'Mark',1 from dual union
    10  select 'Mark',2 from dual;
    Table created.
    SQL> select name
      2  from t
      3  group by name
      4  having count(*) <= 2;
    NAME
    Mark
    SQL>Or another alternative if they aren't sequential:
    SQL> ed
    Wrote file afiedt.buf
      1  select name from (
      2    select name, max(type) t
      3    from t
      4    group by name
      5    )
      6* where t < 3
    SQL> /
    NAME
    Mark
    SQL>Message was edited by:
    blushadow

  • Help with the problem query

    Hi,
    I have another query running slow when executed from cognos. It is also not returning any output continues to execute,
    with "Union15" as (
    select distinct CASE WHEN(substr(to_char(FLOOR("EES_ENERGY_MASTER"."DISC_MON"/100)), 1, 4) IS NULL) OR (case substr(to_char(FLOOR("EES_ENERGY_MASTER"."DISC_MON"/100)), 5, 1) when '1' then 'Q1' when '2' then 'Q2' when '3' then 'Q3' when '4' then 'Q4' end  IS NULL) THEN NULL ELSE (substr(to_char(FLOOR("EES_ENERGY_MASTER"."DISC_MON"/100)), 1, 4)||case substr(to_char(FLOOR("EES_ENERGY_MASTER"."DISC_MON"/100)), 5, 1) when '1' then 'Q1' when '2' then 'Q2' when '3' then 'Q3' when '4' then 'Q4' end ) END "QUARTER", "EES_ENERGY_MASTER"."PAT_KEY" "Cases_Using_Energy", 0 "Total_Cases"
    from "MDM_DBA"."EES_ENERGY_MASTER" "EES_ENERGY_MASTER", "MDM_DBA"."EES_CONS_PROV" "EES_CONS_PROV"
    where "EES_ENERGY_MASTER"."DISC_MON">=2006101 and "EES_ENERGY_MASTER"."PDCT_CAT"='Energy' and substr("EES_ENERGY_MASTER"."ICD_CODE", 1, 2)='68-gyn' and "EES_ENERGY_MASTER"."MANUFACTURER"='EES' and "EES_CONS_PROV"."CONS_06_09_YN" in ('N', 'Y') and "EES_ENERGY_MASTER"."PROV_ID"="EES_CONS_PROV"."PROV_ID" union 
    select CASE WHEN(substr(to_char(FLOOR("MVW_EES_ICD_STATS"."DISC_QTR")), 1, 4) IS NULL) OR (case substr(to_char(FLOOR("MVW_EES_ICD_STATS"."DISC_QTR")), 5, 1) when '1' then 'Q1' when '2' then 'Q2' when '3' then 'Q3' when '4' then 'Q4' end  IS NULL) THEN NULL ELSE (substr(to_char(FLOOR("MVW_EES_ICD_STATS"."DISC_QTR")), 1, 4)||case substr(to_char(FLOOR("MVW_EES_ICD_STATS"."DISC_QTR")), 5, 1) when '1' then 'Q1' when '2' then 'Q2' when '3' then 'Q3' when '4' then 'Q4' end ) END "QUARTER", 0 "Cases_Using_Energy", count("MVW_EES_ICD_STATS"."CASES") "Total_Cases"
    from "MDM_DBA"."MVW_EES_ICD_STATS" "MVW_EES_ICD_STATS", "MDM_DBA"."EES_CONS_PROV" "EES_CONS_PROV", "MDM_DBA"."EES_HOSP_CHG_PROV" "EES_HOSP_CHG_PROV"
    where "MVW_EES_ICD_STATS"."DISC_QTR">=20061 and "MVW_EES_ICD_STATS"."ICD_GROUP"='68-gyn' and "EES_CONS_PROV"."CONS_06_09_YN" in ('N', 'Y') and "EES_HOSP_CHG_PROV"."PDCT_CAT"='Energy' and "EES_HOSP_CHG_PROV"."MANUFACTURER"='EES' and "MVW_EES_ICD_STATS"."PROV_ID"="EES_CONS_PROV"."PROV_ID" and "MVW_EES_ICD_STATS"."PROV_ID"="EES_HOSP_CHG_PROV"."PROV_ID"
    group by CASE WHEN(substr(to_char(FLOOR("MVW_EES_ICD_STATS"."DISC_QTR")), 1, 4) IS NULL) OR (case substr(to_char(FLOOR("MVW_EES_ICD_STATS"."DISC_QTR")), 5, 1) when '1' then 'Q1' when '2' then 'Q2' when '3' then 'Q3' when '4' then 'Q4' end  IS NULL) THEN NULL ELSE (substr(to_char(FLOOR("MVW_EES_ICD_STATS"."DISC_QTR")), 1, 4)||case substr(to_char(FLOOR("MVW_EES_ICD_STATS"."DISC_QTR")), 5, 1) when '1' then 'Q1' when '2' then 'Q2' when '3' then 'Q3' when '4' then 'Q4' end ) END)
    select "T1"."C0" "levelkey", "T1"."C1" "Cases_Using_Energy", "T0"."C0" "Cases_Using_Energy1", "T1"."C2" "Total_Cases"
    from (
    select count(distinct "Union15"."Cases_Using_Energy") "C0"
    from "Union15") "T0", (
    select "Union15"."QUARTER" "C0", count(distinct "Union15"."Cases_Using_Energy") "C1", sum("Union15"."Total_Cases") "C2"
    from "Union15"
    group by "Union15"."QUARTER") "T1"The explain plan is as follows,
    PLAN_TABLE_OUTPUT
    | Id  | Operation                             |  Name                        | Rows  | Bytes |TempSpc| Cost  |
    |   0 | SELECT STATEMENT                      |                              |     1 |    50 |       |    22 |
    |   2 |  TEMP TABLE TRANSFORMATION            |                              |       |       |       |       |
    |   1 |   RECURSIVE EXECUTION                 | SYS_LE_2_0                   |       |       |       |       |
    |   0 |    INSERT STATEMENT                   |                              |  3053 |   128K|       |  1372 |
    |   1 |     LOAD AS SELECT                    |                              |       |       |       |       |
    |   2 |      SORT UNIQUE                      |                              |  3053 |   128K|   376K|  1372 |
    |   3 |       UNION-ALL                       |                              |       |       |       |       |
    |*  4 |        HASH JOIN                      |                              |  3052 |   128K|       |   185 |
    |*  5 |         TABLE ACCESS FULL             | EES_CONS_PROV                |   622 |  3732 |       |     2 |
    |*  6 |         TABLE ACCESS BY INDEX ROWID   | EES_ENERGY_MASTER            |  3055 |   110K|       |   182 |
    |*  7 |          INDEX RANGE SCAN             | IDX_ENERGY_PDCT_CAT          |  1978 |       |       |  2478 |
    |   8 |        SORT GROUP BY                  |                              |     1 |    40 |       |  1160 |
    |*  9 |         TABLE ACCESS BY INDEX ROWID   | EES_HOSP_CHG_PROV            |     4 |    72 |       |     1 |
    |  10 |          NESTED LOOPS                 |                              |     1 |    40 |       |  1157 |
    |  11 |           NESTED LOOPS                |                              |     1 |    22 |       |  1156 |
    |* 12 |            TABLE ACCESS BY INDEX ROWID| MVW_EES_ICD_STATS            |     1 |    16 |       |  1155 |
    |* 13 |             INDEX RANGE SCAN          | MVWICDSTATS_DISCQTR_IDX      |    13M|       |       | 26068 |
    |* 14 |            TABLE ACCESS BY INDEX ROWID| EES_CONS_PROV                |     1 |     6 |       |     1 |
    |* 15 |             INDEX UNIQUE SCAN         | EES_CONS_PROV_PK             |     1 |       |       |       |
    |* 16 |           INDEX RANGE SCAN            | PROV_ID_IDX_2                |    65 |       |       |     1 |
    |   3 |   MERGE JOIN CARTESIAN                |                              |     1 |    50 |       |    22 |
    |   4 |    VIEW                               |                              |     1 |    13 |       |     3 |
    |   5 |     SORT GROUP BY                     |                              |     1 |    13 |       |       |
    |   6 |      VIEW                             |                              |  3053 | 39689 |       |     3 |
    |   7 |       TABLE ACCESS FULL               | SYS_TEMP_0FD9D68B3_C112F95D  |  3053 |   110K|       |     3 |
    |   8 |    VIEW                               |                              |     1 |    37 |       |    19 |
    |   9 |     SORT GROUP BY                     |                              |     1 |    37 |       |    19 |
    |  10 |      VIEW                             |                              |  3053 |   110K|       |     3 |
    |  11 |       TABLE ACCESS FULL               | SYS_TEMP_0FD9D68B3_C112F95D  |  3053 |   110K|       |     3 |
    Predicate Information (identified by operation id):
       4 - access("EES_ENERGY_MASTER"."PROV_ID"="EES_CONS_PROV"."PROV_ID")
       5 - filter("EES_CONS_PROV"."CONS_06_09_YN"='N' OR "EES_CONS_PROV"."CONS_06_09_YN"='Y')
       6 - filter("EES_ENERGY_MASTER"."DISC_MON">=2006101 AND SUBSTR("EES_ENERGY_MASTER"."ICD_CODE",1,2)='68-gyn'
                  AND "EES_ENERGY_MASTER"."MANUFACTURER"='EES')
       7 - access("EES_ENERGY_MASTER"."PDCT_CAT"='Energy')
       9 - filter("EES_HOSP_CHG_PROV"."PDCT_CAT"='Energy' AND "EES_HOSP_CHG_PROV"."MANUFACTURER"='EES')
      12 - filter("MVW_EES_ICD_STATS"."ICD_GROUP"='68-gyn')
      13 - access("MVW_EES_ICD_STATS"."DISC_QTR">=20061 AND "MVW_EES_ICD_STATS"."DISC_QTR" IS NOT NULL)
      14 - filter("EES_CONS_PROV"."CONS_06_09_YN"='N' OR "EES_CONS_PROV"."CONS_06_09_YN"='Y')
      15 - access("MVW_EES_ICD_STATS"."PROV_ID"="EES_CONS_PROV"."PROV_ID")
      16 - access("MVW_EES_ICD_STATS"."PROV_ID"="EES_HOSP_CHG_PROV"."PROV_ID")
    Please help with some solution.

    OK: the third parameter of the SUBSTR function indicates the (maximum) length of the returnd string.
    Therefore SUBSTR("EES_ENERGY_MASTER"."ICD_CODE",1,2) could possibly be '68' , but never '68-gyn'.
    '68-gyn' is just 4 characters too long.
    Urs

  • Need help with writing a query with dynamic FROM clause

    Hi Folks,
    I need help with an query that should generate the "FROM" clause dynamically.
    My main query is as follows
    select DT_SKEY, count(*)
    from *???*
    where DT_SKEY between 20110601 and 20110719
    group by DT_SKEY
    having count(*) = 0
    order by 1; The "from" clause of the above query should be generated as below
    select 'Schema_Name'||'.'||TABLE_NAME
    from dba_tables
    where OWNER = 'Schema_Name'Simply sticking the later query in the first query does not work.
    Any pointers will be appreciated.
    Thanks
    rogers42

    Hi,
    rogers42 wrote:
    Hi Folks,
    I need help with an query that should generate the "FROM" clause dynamically.
    My main query is as follows
    select DT_SKEY, count(*)
    from *???*
    where DT_SKEY between 20110601 and 20110719
    group by DT_SKEY
    having count(*) = 0
    order by 1; The "from" clause of the above query should be generated as below
    select 'Schema_Name'||'.'||TABLE_NAME
    from dba_tables
    where OWNER = 'Schema_Name'
    Remember that anything inside quotes is case-sensitive. Is the owner really "Schema_Name" with a capital S and a capital N, and 8 lower-case letters?
    Simply sticking the later query in the first query does not work.Right; the table name must be given when you compile the query. It's not an expression that you can generate in the query itself.
    Any pointers will be appreciated.In SQL*Plus, you can do something like the query bleow.
    Say you want to count the rows in scott.emp, but you're not certain that the name is emp; it could be emp_2011 or emp_august, or anything else that starts with e. (And the name could change every day, so you can't just look it up now and hard-code it in a query that you want to run in the future.)
    Typically, how dynamic SQL works is that some code (such as a preliminary query) gets some of the information you need to write the query first, and you use that information in a SQL statement that is compiled and run after that. For example:
    -- Preliminary Query:
    COLUMN     my_table_name_col     NEW_VALUE my_table_name
    SELECT     table_name     AS my_table_name_col
    FROM     all_tables
    WHERE     owner          = 'SCOTT'
    AND     table_name     LIKE 'E%';
    -- Main Query:
    SELECT     COUNT (*)     AS cnt
    FROM     scott.&my_table_name
    ;This assumes that the preliminary query will find exactly one row; that is, it assumes that SCOTT has exactly one table whose name starts with E. Could you have 0 tables in the schema, or more than 1? If so, what results would you want? Give a concrete example, preferably suing commonly available tables (like those in the SCOTT schema) so that the poepl who want to help you can re-create the problem and test their ideas.
    Edited by: Frank Kulash on Aug 11, 2011 2:30 PM

  • Help with a update query from a subquery

    Hello All,
    I wanted to see if someone can help me with an update query.
    I need to grab a latitude & longitude from a the same user that is in two accounts. therefore i am trying to update lat/long in a users table for one account based off of the same user in another account. I am matching the users up by phone number and last name. I tried a subquery but am having difficulty.
    I was thinking of something like the following:
    update users
    set lat = getlat, long = getlong
    inner join (select lat as getlat, long as get long from users where account_id = '1')
    on phone = phone and last name = lastname
    where account_id = '2' and lat IS NULL and long IS NULL
    Am I going in the right direction???
    Thanks in advance for any assistance!!!!

    What difficulty are you having? Have you tried what you posted and get an error?
    Although someone may be able to give you sql advice here, I would try posting this over at Stack Overflow as its not really related to Coldfusion.

  • Help With Geodetic Rectangular Query Please

    I'm new to spatial so I appreciate your help.
    I have a 3D geodetic coordinate system defined that is index in 2D (lon & lat).
    I want to do a query that returns all points (lat, lon, alt) within the rectangle described by the query.
    I read in the "Oracle Spatial User's Guide" that this rectangle must have 5 points (since I'm using geodetic).
    I have not found a good example of how to format the query. Can you help with an example?

    here is an example which assume a wgs-84 coordinate system (srid=8307). Note that altitude will be ignored.
    select col1,col2,etc
    from geom_table
    where sdo_relate(geom,mdsys.sdo_geometry(2003,8307,NULL,
    mdsys.sdo_elem_info_array(1,1003,1),
    mdsys.sdo_ordinate_array(-70.05,40.8, -69.05,40.8, -69.05,41.2, -70.05,41.2, -70.05,40.8)),
    'mask=anyinteract querytype=window') = 'TRUE';

  • Need help with the following query

    I have the following data
    INVOICE_ID PAID_AMT PYMNT_GROSS_AMT DISCOUNT
    10151 1375 1375 55
    10151DC -44.81 -44.81 0
    20017 25 25 7
    Ok the data I want to grab the discount field is paid_amt = pymnt_gross_amt and discount <> 0. If however there is another invoice_id out there (same invoice ID except with a DC appended to it like 10151DC) then you want to select the differece between the discount field without the DC and the Invoice ID with the DC the paid_amt field.
    So the results would be.
    Invoice_ID Discount
    10151 10.19
    20017 7
    Thanks for all your help!

    Why scan same table twice when it can be achived using single scan :
    Hope this helps :
    with inv_data as
    (select '10151' invoice_id,
    1375 paid_amt,
              1375 pymnt_gross_amt,
              55 discount from dual
    union all
    select '10151DC' invoice_id,
    -44.81 paid_amt,
              -44.81 pymnt_gross_amt,
              0 discount from dual
    union all
    select '20017' invoice_id,
    25 paid_amt,
              25 pymnt_gross_amt,
              7 discount from dual)
    select replace(invoice_id,'DC') invoice_id,
    sum(case when invoice_id like '%DC' then pymnt_gross_amt
         else discount end) discount
    from inv_data
    group by replace(invoice_id,'DC')
    INVOICE DISCOUNT
    10151 10.19
    20017 7
    2 rows selected.

  • Help with nested select query

    Here is my code , i dont have any experience with writing the nested sql , i got the below code , which needs to be modified adding a case statement which will show util_rate for 2 conditions
    1. given in where condition ( to_char(time_stamp,'HH24') >= '09' and to_char(time_stamp,'HH24') <= '19')
    2.Apposite to the condition above (to_char(time_stamp,'HH24') < '09'and to_char(time_stamp,'HH24') > '19')
    could anybody please help me in adding the 2nd condition to the below query , please share any documentation you have for learning how to write nested sql,
    Thank you
    select device,time_stamp,
    sum(ActiveHRS)/sum(AvailHRS) as RATE
    from
    select device,time_stamp,
    case when usage >0 then 1
    else 0 end as ActiveHRS,
    '1' as AvailHRS
    from
    select device,time_stamp,
    sum(case
    when state = 9 then 0
    when state = 0 then 0
    else 1 end) as usage
    from A
    where to_char(time_stamp,'HH24') >= '09'
    and to_char(time_stamp,'HH24') <= '19'
    and to_char(time_stamp, 'D') in (2,3,4,5,6)
    group by device, time_stamp
    group by device,time_stamp

    Here is the DDL :
    desc rumi_all
    Name     Null   Type    
    RUMI_DEVICE      VARCHAR2(20)
    STATE         NUMBER(38) 
    TIME_STAMP      DATE     
    LOCATION       VARCHAR2(50) Here is some sample data :
    RUMI_DEVICE   STATE   TIME_STAMP    LOCATION
    10.45.28.86     0     15-JUN-10      WA-102
    10.45.28.51     0     15-JUN-10      WA-102
    10.45.28.63     0     15-JUN-10      WA-102
    10.45.29.47     9     15-JUN-10      WA-120I used the below query to get the util for the hours 9am - 7pm
    select rumi_device,time_stamp,
    sum(ActiveHRS)/sum(AvailHRS) as RATE
    from
    select rumi_device,time_stamp,
    case when usage >0 then 1
    else 0 end as ActiveHRS,
    '1' as AvailHRS
    from
    select rumi_device,time_stamp,
    sum(case
    when state = 9 then 0
    when state = 0 then 0
    else 1 end) as usage
    from rumi_all
    where to_char(time_stamp,'HH24') >= '09'
    and to_char(time_stamp,'HH24') <= '19'
    and to_char(time_stamp, 'D') in (2,3,4,5,6)
    group by rumi_device, time_stamp
    group by rumi_device,time_stamp
    Acquired Out for the above query :
    RUMI_DEVICE      TIME_STAMP     UTIL_RATE
    10.45.29.47     15-JUN-10       0.234
    10.45.28.63     15-JUN-10             0.123
    10.45.29.47     15-JUN-10             0.987
    10.45.29.47     16-JUN-10             0.23Desired output :I want 2 extra columns which shows util rate for the above condition i.e 9am - 7pm(core hours) and also opposite to that condition after 7pm - before 9am(say, non core hours)
    Desired out put :
    RUMI_DEVICE TIME_STAMP  Core_Util_Rate   Non_Core_UtilRate
    10.45.29.4    15-JUN-10       0.234              0.003
    10.45.28.63   15-JUN-10     0.123              0.001
    10.45.29.47   15-JUN-10              0.987              0.023
    10.45.29.47   16-JUN-10              0.23                  0Hope this helps in answering my question , and also could you please share some document to learn writing nested sql's , i always had tough time in understanding this :-(

  • Please help with an embedded query (INSERT RETURNING BULK COLLECT INTO)

    I am trying to write a query inside the C# code where I would insert values into a table in bulk using bind variables. But I also I would like to receive a bulk collection of generated sequence number IDs for the REQUEST_ID. I am trying to use RETURNING REQUEST_ID BULK COLLECT INTO :REQUEST_IDs clause where :REQUEST_IDs is another bind variable
    Here is a full query that use in the C# code
    string sql = "INSERT INTO REQUESTS_TBL(REQUEST_ID, CID, PROVIDER_ID, PROVIDER_NAME, REQUEST_TYPE_ID, REQUEST_METHOD_ID, " +
    "SERVICE_START_DT, SERVICE_END_DT, SERVICE_LOCATION_CITY, SERVICE_LOCATION_STATE, " +
    "BENEFICIARY_FIRST_NAME, BENEFICIARY_LAST_NAME, BENEFICIARY_DOB, HICNUM, CCN, " +
    "CLAIM_RECEIPT_DT, ADMISSION_DT, BILL_TYPE, LANGUAGE_ID, CONTRACTOR_ID, PRIORITY_ID, " +
    "UNIVERSE_DT, REQUEST_DT, BENEFICIARY_M_INITIAL, ATTENDING_PROVIDER_NUMBER, " +
    "BILLING_NPI, BENE_ZIP_CODE, DRG, FINAL_ALLOWED_AMT, STUDY_ID, REFERRING_NPI) " +
    "VALUES " +
    "(SQ_CDCDATA.NEXTVAL, :CIDs, :PROVIDER_IDs, :PROVIDER_NAMEs, :REQUEST_TYPE_IDs, :REQUEST_METHOD_IDs, " +
    ":SERVICE_START_DTs, :SERVICE_END_DTs, :SERVICE_LOCATION_CITYs, :SERVICE_LOCATION_STATEs, " +
    ":BENEFICIARY_FIRST_NAMEs, :BENEFICIARY_LAST_NAMEs, :BENEFICIARY_DOBs, :HICNUMs, :CCNs, " +
    ":CLAIM_RECEIPT_DTs, :ADMISSION_DTs, :BILL_TYPEs, :LANGUAGE_IDs, :CONTRACTOR_IDs, :PRIORITY_IDs, " +
    ":UNIVERSE_DTs, :REQUEST_DTs, :BENEFICIARY_M_INITIALs, :ATTENDING_PROVIDER_NUMBERs, " +
    ":BILLING_NPIs, :BENE_ZIP_CODEs, :DRGs, :FINAL_ALLOWED_AMTs, :STUDY_IDs, :REFERRING_NPIs) " +
    " RETURNING REQUEST_ID BULK COLLECT INTO :REQUEST_IDs";
    int[] REQUEST_IDs = new int[range];
    cmd.Parameters.Add(":REQUEST_IDs", OracleDbType.Int32, REQUEST_IDs, System.Data.ParameterDirection.Output);
    However, when I run this query, it gives me a strange error ORA-00925: missing INTO keyword. I am not sure what that error means since I am not missing any INTOs
    Please help me resolve this error or I would appreciate a different solution
    Thank you

    It seems you are not doing a bulk insert but rather an array bind.
    (Which you will also find that it is problematic to do an INSERT with a bulk collect returning clause (while this works just fine for update/deletes) :
    http://www.oracle-developer.net/display.php?id=413)
    But you are using array bind, so you simply just need to use a
    ... Returning REQUEST_ID INTO :REQUEST_IDand that'll return you a Rquest_ID[]
    see below for a working example (I used a procedure but the result is the same)
    //Create Table Zzztab(Deptno Number, Deptname Varchar2(50) , Loc Varchar2(50) , State Varchar2(2) , Idno Number(10)) ;
    //create sequence zzzseq ;
    //CREATE OR REPLACE PROCEDURE ZZZ( P_DEPTNO   IN ZZZTAB.DEPTNO%TYPE,
    //                      P_DEPTNAME IN ZZZTAB.DEPTNAME%TYPE,
    //                      P_LOC      IN ZZZTAB.LOC%TYPE,
    //                      P_State    In Zzztab.State%Type ,
    //                      p_idno     out zzztab.idno%type
    //         IS
    //Begin
    //      Insert Into Zzztab (Deptno,   Deptname,   Loc,   State , Idno)
    //                  Values (P_Deptno, P_Deptname, P_Loc, P_State, Zzzseq.Nextval)
    //                  returning idno into p_idno;
    //END ZZZ;
    //Drop Procedure Zzz ;
    //Drop Sequence Zzzseq ;
    //drop Table Zzztab;
      class ArrayBind
        static void Main(string[] args)
          // Connect
            string connectStr = GetConnectionString();
          // Setup the Tables for sample
          Setup(connectStr);
          // Initialize array of data
          int[]    myArrayDeptNo   = new int[3]{1, 2, 3};
          String[] myArrayDeptName = {"Dev", "QA", "Facility"};
          String[] myArrayDeptLoc  = {"New York", "Chicago", "Texas"};
          String[] state = {"NY","IL","TX"} ;
          OracleConnection connection = new OracleConnection(connectStr);
          OracleCommand    command    = new OracleCommand (
            "zzz", connection);
          command.CommandType = CommandType.StoredProcedure;
          // Set the Array Size to 3. This applied to all the parameter in
          // associated with this command
          command.ArrayBindCount = 3;
          command.BindByName = true;
          // deptno parameter
          OracleParameter deptNoParam = new OracleParameter("p_deptno",OracleDbType.Int32);
          deptNoParam.Direction       = ParameterDirection.Input;
          deptNoParam.Value           = myArrayDeptNo;
          command.Parameters.Add(deptNoParam);
          // deptname parameter
          OracleParameter deptNameParam = new OracleParameter("p_deptname", OracleDbType.Varchar2);
          deptNameParam.Direction       = ParameterDirection.Input;
          deptNameParam.Value           = myArrayDeptName;
          command.Parameters.Add(deptNameParam);
          // loc parameter
          OracleParameter deptLocParam = new OracleParameter("p_loc", OracleDbType.Varchar2);
          deptLocParam.Direction       = ParameterDirection.Input;
          deptLocParam.Value           = myArrayDeptLoc;
          command.Parameters.Add(deptLocParam);
          //P_STATE -- -ARRAY
          OracleParameter stateParam = new OracleParameter("P_STATE", OracleDbType.Varchar2);
          stateParam.Direction = ParameterDirection.Input;
          stateParam.Value = state;
          command.Parameters.Add(stateParam);
                  //idParam-- ARRAY
          OracleParameter idParam = new OracleParameter("p_idno", OracleDbType.Int64 );
          idParam.Direction = ParameterDirection.Output ;
          idParam.OracleDbTypeEx = OracleDbType.Int64;
          command.Parameters.Add(idParam);
          try
            connection.Open();
            command.ExecuteNonQuery ();
            Console.WriteLine("{0} Rows Inserted", command.ArrayBindCount);
              //now cycle through the output param array
            foreach (Int64 i in (Int64[])idParam.Value)
                Console.WriteLine(i);
          catch (Exception e)
            Console.WriteLine("Execution Failed:" + e.Message);
          finally
            // connection, command used server side resource, dispose them
            // asap to conserve resource
            connection.Close();
            command.Dispose();
            connection.Dispose();
          Console.WriteLine("Press Enter to finish");
          Console.ReadKey();
        }

  • Help with a Discoverer Query

    Hi
    can anyone help me create the fields I need below.
    I have a table in disco, below is an extract.
    Subj     Parent     Subj Desc
    5001     P500     Non-Executive Dir
    P500     PBOA     Chairman & Non-Executives
    PBOA     PAYX     PAY BOARD
    PAYX     EXPE     PAY EXPENDITURE
    EXPE     INCE     GROSS EXPENDITURE
    INCE     TOTA     INCOME AND EXPENDITURE
    For each line in the above I want to create 6 levels which will contain all the parents.
    eg
              Level 1     Level 2     Level 3     Level 4 Level 5     Level 6
    5001     Non-Executive Dir     P500     PBOA     PAYX     EXPE     INCE     TOTA
    I only need this for the bottom level which ranges from 0000 to 9999
    i.e. I won't need this for P500 etc .
    Hope this make sense.
    Thanks for your continued help.
    Andy

    Hi,
    There are basically two ways you can do this. Either create a custom folder that contains a hierarchical query, e.g.
    select substr(subj_path, 2, instr(subj_path, ',', 1,2)-2) subj,
    substr(desc_path, instr(desc_path, ',' ,1,1)+1, instr(desc_path, ',' ,1, 2) - instr(desc_path, ',' ,1, 1)-1) level1,
    substr(desc_path, instr(desc_path, ',' ,1,2)+1, instr(desc_path, ',' ,1, 3) - instr(desc_path, ',' ,1, 2)-1) level2,
    substr(desc_path, instr(desc_path, ',' ,1,3)+1, instr(desc_path, ',' ,1, 4) - instr(desc_path, ',' ,1, 3)-1) level3,
    substr(desc_path, instr(desc_path, ',' ,1,4)+1, instr(desc_path, ',' ,1, 5) - instr(desc_path, ',' ,1, 4)-1) level4,
    substr(desc_path, instr(desc_path, ',' ,1,5)+1, instr(desc_path, ',' ,1, 6) - instr(desc_path, ',' ,1, 5)-1) level5,
    substr(desc_path, instr(desc_path, ',' ,1,6)+1, instr(desc_path, ',' ,1, 7) - instr(desc_path, ',' ,1, 6)-1) level6
    from (
    select sys_connect_by_path (subj_desc, ',')||',' desc_path, sys_connect_by_path (subj, ',')||',' subj_path, level slevel from subject
    connect by subj = prior subj_parent start with subj between '0000' and '9999'
    ) a
    where slevel=6
    Alternatively, create level1 complex folder in the EUL and drag in the contents of your subject folder. Then join it to the subject folder using subject.parent = level1.subj. Then create a level2 folder in the same way and join it to the level1 folder. Continue in this way until you have done all 6 levels. You will then be able to create a report taking a level from each folder.
    Rod West

Maybe you are looking for

  • Can I return my new laptop to lenovo because of its quality problem?

    IBM is one of the best brand as I know, especially showing us not only high quality of products but the service. But now one thing happened to me, if I don't have this case I can't believe. I found there is something with the laptop(T61 Model 7658CTO

  • How to format FAT drive as MAC OS EXTENDED?

    Hello, Does anybody can help me to format a FAT drive as MAC OS EXTENDED? It is an external FW drive. I cannot find the way in the laptop. Thanks!!

  • HELP! Gray Screen & File Folder with Question Mark!

    Hello! If anyone can offer suggestions or if you've dealt with this before I would love feedback so that we can fix this problem! I recently converted my husband from a PC user to a Mac user (it was a happy day). A little over 1 month ago we bought a

  • PROJECT MANAGEMENT SOFTWARE - MAC OS X & MS-PROJECT

    Hi Folks, I need some advice! I am looking for some good Project Management Software to run on my MAC OS X. Mostly, I will do be doing Gantt Charts, Critical Path, Resource Loading, Task Creation, Etc. My clients typcially run MS-PROJECT on PCs--so I

  • PackageMaker: Set Permissions on Applications Subdirectory

    Hello everyone -- I'm new to the Apple package making process and running into some interesting issues. I developed a series of scripts wrapped into Automator applications which I want to deploy to a subdirectory of Applications (ex /Applications/Myp