Query to get summary for two types of row data

Hi Friends,
I have tried using aggregate functions and thought of using analytic functions and still trying... But I am sure some analytic function expert can quickly help me out in this.
With this data.
BID_ELMT_SEQ_ID     PRF_NO          BID_REQ_DT          BID_ATRB_TYP_CD          BID_ATRB_VAL
3575758          1          1/24/2011 2:27:32 PM     MINDAYS               1
3575758          1          1/24/2011 2:27:32 PM     WRAPDAYS          1-0
3575759          2          1/24/2011 2:27:32 PM     MINDAYS               1
3575759          2          1/24/2011 2:27:32 PM     WRAPDAYS          1-0
3575760          3          1/24/2011 2:27:32 PM     MINDAYS               1
3575760          3          1/24/2011 2:27:32 PM     WRAPDAYS          1-0
3575761          4          1/24/2011 2:27:32 PM     MINDAYS               1
3575761          4          1/24/2011 2:27:32 PM     WRAPDAYS          1-0 Is it possible to retrieve an output similar to this ? In short , the row values of BID_ATRB_TYP_CD to be grouped into two columns and values fetched for this
BID_ELMT_SEQ_ID     PRF_NO          BID_REQ_DT          MIN_DAYS_VAL     WRAP_DAYS_VAL
3575758          1          1/24/2011 14:27          1          1-0
3575759          2          1/24/2011 14:27          1          1-0
3575760          3          1/24/2011 14:27          1          1-0
3575761          4          1/24/2011 14:27          1          1-0 Regards,
SSN

Looks pretty simple to me - I haven't tried it yet.
Can you share what you have tried so far and what has been the outcome of that effort?

Similar Messages

  • Same query takes different time for two different users with same privileges

    Hi,
    Just wanted to know if it is possible for an INSERT query to take different amount of time for two different users for the same volume of data. If so, what could be the reason? I would like to add that we are not executing the query simultaneously. But it is always faster for user1(within 10-20 seconds) and slower for user2(takes around 8-10 minutes).

    Show execution plan for each user. I think there is other reasons which you didn't not tell

  • SQL query to get DDL for Adding PK.

    Guys,
    I'm looking for SQL query that gets me the "ALTER TABLE <TABLE_NAME> ADD CONSTRAINT <constraint_name> PRIMARY KEY (X,Y,...);" statments of all tables in my schema containing Primary Keys.
    Could someone help me with the query please?
    Regards,
    Bhagat

    You need this
    SELECT 'ALTER TABLE '||table_name||' ADD CONSTRAINT '||constraint_name||' PRIMARY KEY ('||column_name||');'
      FROM ( SELECT uc.table_name
                   ,uc.constraint_name
                   ,RTRIM (XMLAGG (XMLELEMENT (ucc, column_name || ',')).extract ('//text()'), ',')  column_name
              FROM user_constraints        uc
                  ,user_cons_columns       ucc
             WHERE uc.constraint_type      = 'P'
               AND uc.constraint_name      = ucc.constraint_name
          GROUP BY uc.table_name
                  ,uc.constraint_name
    ORDER BY table_name;   Regards
    Arun

  • Calling first query to get parameters for second query

    Newbie trying to convert an Oracle Report to BI. The report has 1 parameter from the user, which is plugged into a query that returns grouped data (4 values, 1 row). This data is then used in multiple places (not just where clause) in a second query to get the data for the report. Can anyone please point me in the right direction to accomplish this?
    I have looked at using a before trigger possibly to get the first query values but am not sure how to then pass those values back to be used by the second query.
    Thank you for ANY suggestions!

    Hello,
    you use any fields in additional querys as parameters.
    If you use XML-data-template, it would look like this:
    <dataTemplate name="INVOICE_REPORT" description="Invoice Report" Version="1.0">
      <parameters>
        <parameter name="P_INVOICE_HEADER_ID" dataType="number"/>
      </parameters>
      <dataQuery>
        <sqlStatement name="QUERY_INVOICE">
          <![CDATA[
    select ivh.invoice_header_id    
         , ivh.invoice_number
         , ivh.customer_id           // here you select the field which is a parameter for next query
          -- ... additional fields ... --
      from tbl_invoices ivh
      where ivh.invoice_header_id = :P_INVOICE_HEADER_ID
        -- and additonal conditions --
    ]]>
        </sqlStatement>
        <sqlStatement name="QUERY_CUSTOMER">
          <![CDATA[
    SELECT c.account_number
         , c.customer_name
         , c.customer_city
          -- ... additional fields ... --
      FROM tbl_customers c
      where c.customer_id = :CUSTOMER_ID // here is the parameter
        -- and additonal conditions --
    ]]>
        </sqlStatement>
      </dataQuery>
      <dataStructure>
        <group name="GRP_HEADER" source="QUERY_INVOICE">
          <element name="INVOICE_HEADER_ID" value="INVOICE_HEADER_ID"/>
          <element name="INVOICE_NUMBER" value="INVOICE_NUMBER"/>
          <group name="GRP_LINE" source="QUERY_INVOICE">
            <element name="ACCOUNT_NUMBER" value="ACCOUNT_NUMBER"/>
            <element name="CUSTOMER_NAME" value="CUSTOMER_NAME"/>
            <element name="CUSTOMER_CITY" value="CUSTOMER_CITY"/>
          </group>
        </group>
      </dataStructure>
    </dataTemplate>          The behavoir is much similar to oracle report
    Regards
    Alexander
    Edited by: alexander.steinbeisz on Dec 7, 2009 12:20 PM
    Edited by: alexander.steinbeisz on Dec 7, 2009 12:21 PM

  • Getting charged for two subscriptions

    I seem to be getting charged for a single subscription as well as my newly upgraded team subscription.
    10-September-2014 (PT) – 09-October-2014 (PT)
    2
    Subtotal: AUD99.98
    VAT/Tax: AUD0.00  Total: AUD99.98
    and 14/9/14
    Billed to:
    ~~~
    ~~~
    ~~~
    AU
    Tasmania
    Membership details:
    Creative Cloud membership (one-year)
    Subtotal: 49.99 AUD
    Tax/VAT: 0.00 AUD
    Total payment today:  49.99 AUD
    Can this be confirmed if it's happening or not?
    Thanks,
    Toby

    Cancel the one you don't want
    Cancel http://helpx.adobe.com/x-productkb/policy-pricing/return-cancel-or-change-order.html
    -or by telephone http://helpx.adobe.com/x-productkb/global/phone-support-orders.html

  • % is not getting correctly for the Grand Total Row in OBI10g

    Hi,We have a report in table view with the following structure.
    Name     Target     Act     %Ach
    ABC     100     50     50
    XYZ     200     10     5
    Total     300     60     27.5
    The value for the %Ach Total row should be 20% but in the report it is showing as 27.5.
    any one observed this ,how to correct this??
    Thanks

    Hi,
    To get grand total correctly..configure instanceconfig.xml and put..
    <ReportAggregateEnabled>true</ReportAggregateEnabled> between <serverinstace>..
    refer..
    http://obiee101.blogspot.com/2009/09/obiee-grand-totals-with-calculated.html
    Hope it solves ur problem

  • How to modify the query to get the output in a single row

    Hi All,
    Below is the query i have written it works fine
    select DISTINCT right(left(CTACCT,13),4) AS LocationNum,
    tODS_GLBalance.FiscalYearId AS FiscalYearId,
    tODS_GLBalance.FiscalMonthOfYearId AS FiscalMonthOfYearId,
    --tods_GLMetadata.Metric,
    Case when
    tods_GLMetadata.Metric = 'Gross Margin'
    Then SUM(Balance)
    Else 0
    END AS GrossMargin,
    Case when
    tods_GLMetadata.Metric = 'Occupancy'
    Then SUM(Balance)
    Else 0
    END AS Occupancy,
    Case when
    tods_GLMetadata.Metric = 'Payroll Dollars'
    Then SUM(Balance)
    Else 0
    END AS Payroll,
    Case when
    tods_GLMetadata.Metric = 'CF Sales'
    Then SUM(Balance)
    Else 0
    END AS OperatingSales,
    Case when
    tods_GLMetadata.Metric = 'Operations'
    Then SUM(Balance)
    Else 0
    END AS OperatingExpenses
    -- 0 as payroll
    from ods.[JJill].[tODS_GLBalance]
    inner join ods.Staging.tODS_INF_GLPCT ON tODS_GLBalance.PageNum = tODS_INF_GLPCT.CTPAGE
    inner join ods.JJill.tods_GLMetadata ON tods_GLMetadata.AcctDescription = tODS_INF_GLPCT.CTDESC
    where
    (tODS_GLBalance.FiscalYearId = 2012) and
    (tODS_GLBalance.FiscalMonthOfYearId = 2) and
    (right(left(CTACCT,13),4)= 3020)
    group by
    right(left(CTACCT,13),4),
    tODS_GLBalance.FiscalYearId,
    tODS_GLBalance.FiscalMonthOfYearId,
    tods_GLMetadata.Metric
    This is the sample output,
    LocationNum FiscalYearId FiscalMonthOfYearId GrossMargin Occupancy Payroll OperatingSales OperatingExpenses
    3020 2012 2 -112477.00 0.00 0.00 0.00 0.00
    3020 2012 2 0.00 0.00 0.00 -158288.94 0.00
    3020 2012 2 0.00 0.00 0.00 0.00 5625.44
    3020 2012 2 0.00 0.00 24185.79 0.00 0.00
    3020 2012 2 0.00 31075.53 0.00 0.00 0.00
    But, i am expecting the output to be something like this
    LocationNum FiscalYearId FiscalMonthOfYearId GrossMargin Occupancy Payroll OperatingSales OperatingExpenses
    3020 2012 2 -112477.00 31075.53 24185.79 -158288.94 5625.44
    Can someone please help me with changing my query to get the desired output?
    Please let me know if you have any questions.
    Thanks

    Try this:
    SELECT DISTINCT
    RIGHT(LEFT(CTACCT,13),4) AS LocationNum, tODS_GLBalance.FiscalYearId AS FiscalYearId, tODS_GLBalance.FiscalMonthOfYearId AS FiscalMonthOfYearId,
    SUM(CASE WHEN tods_GLMetadata.Metric = 'Gross Margin' THEN Balance ELSE 0 END ) AS GrossMargin,
    SUM(CASE WHEN tods_GLMetadata.Metric = 'Occupancy' THEN Balance ELSE 0 END ) AS Occupancy,
    SUM(CASE WHEN tods_GLMetadata.Metric = 'Payroll Dollars' THEN Balance ELSE 0 END ) AS Payroll,
    SUM(CASE WHEN tods_GLMetadata.Metric = 'CF Sales' THEN Balance ELSE 0 END ) AS OperatingSales,
    SUM(CASE WHEN tods_GLMetadata.Metric = 'Operations' THEN Balance ELSE 0 END ) AS OperatingExpenses
    FROM ods.[JJill].[tODS_GLBalance]
    INNER JOIN ods.Staging.tODS_INF_GLPCT
    ON tODS_GLBalance.PageNum = tODS_INF_GLPCT.CTPAGE
    INNER JOIN ods.JJill.tods_GLMetadata
    ON tods_GLMetadata.AcctDescription = tODS_INF_GLPCT.CTDESC
    WHERE tODS_GLBalance.FiscalYearId = 2012
    AND tODS_GLBalance.FiscalMonthOfYearId = 2
    AND RIGHT(LEFT(CTACCT,13),4) = 3020
    GROUP BY right(left(CTACCT,13),4), tODS_GLBalance.FiscalYearId, tODS_GLBalance.FiscalMonthOfYearId, tods_GLMetadata.Metric

  • Extension type for mime-type "multipart/form-data"

              Hello:
              If I want to register a mime-type of type "multipart/form-data" in WebLogic 6.0
              what, if any, extension should I specify fot it in the web.xml? Is it necessary
              to specify this mime-type for handling "multipart/form-data" type http requests?
              Thanks
              John
              

    You cannot use request.getParameter() for Multipart/form-data.
              You need to Use getInputStream and use the InputStream to read data.
              Please Refer Jeason Hunters Implementation for the same. Its a very good example.
              Kumar.
              John Buckley wrote:
              > Hmm. Strange. When I send in a multipart/form-data request and when I try to do
              > a request.getParameter within my servlet it returns null and also throws a socket
              > exception at the server console.
              >
              > Any ideas?
              >
              > John
              >
              > Mettu Kumar <[email protected]> wrote:
              > >I don't think its neccesary as I am able to run my code with wls6.0 without
              > >registering
              > >multipart/form-data.
              > >
              > >kumar.
              > >John Buckley wrote:
              > >
              > >> Hello:
              > >> If I want to register a mime-type of type "multipart/form-data" in
              > >WebLogic 6.0
              > >> what, if any, extension should I specify fot it in the web.xml? Is
              > >it necessary
              > >> to specify this mime-type for handling "multipart/form-data" type http
              > >requests?
              > >>
              > >> Thanks
              > >>
              > >> John
              > >
              

  • SQL query to find top 5 users having more rows/data in table

    Dear experts,
    OS = HP-UX
    Database = Oracle 9.2.0.8
    AC users = 600
    Ex:-
    select * from all_users where username like 'AC%';
    AC_1
    AC_2
    AC_3
    AC_4
    AC_5
    AC_6
    AC_.
    AC_.
    AC_.
    AC_600
    Each AC user having same tables INCOMING, OUTGOING
    Now i need to find top 5 users having more rows/data in INCOMING , OUTGOING tables. I tried this:
    SQL>conn AC_1/pwd
    select 'select count(*) from '||table_name||';' from user_tables;
    But i get max counts info only for this AC_1 user , however, i need top 5 users having more rows/max counts query.
    Thank you,

    source : oracle forums
    May be , this one.. not tested though.
    Before doing this you need to have select_catalog_role
    WITH tmp
         AS (SELECT owner,
                    table_name,
                    TO_NUMBER (
                       EXTRACTVALUE (
                          xmltype (
                             DBMS_XMLGEN.getxml (
                                'select /*+ PARALLEL*/ count(*) c from '
                                || table_name)),
                          '/ROWSET/ROW/C'))
                       Cnt
               FROM dba_tables
              WHERE 1 = 1 AND table_name IN ('INCOMING', 'OUTGOING')),
         tmp1
         AS (SELECT a.*,
                    MAX (cnt)
                       OVER (PARTITION BY a.table_name ORDER BY a.cnt DESC)
                       maxcnt
               FROM tmp a)
    SELECT DISTINCT a.*
      FROM tmp a, tmp1 b
    WHERE a.cnt = b.maxcnt AND a.table_name = b.table_name;

  • Accounting documents not getting generated for mvt. type 221 Q

    Hi friends,
    When goods are issued for consumption for project accounting documents are not getting generated.
    I have tried with mvt. type 412 Q, 211 Q,
    by mvt type 412 Q, the stock is transfered to project stock, it shows the stock of material in project stock, by movement type 211 Q the project stock gets consumed. So at the time of consumption of consumption account should hit and relevent accounting document should get generated. this is not happenning.
    When i check material document and check for accounting document, message flashses that movement is not rrelevent for accounting.
    Can any one throw more light on this?
    Thanks and regards
    SAP MM

    Hi,
    Please check in PO item details Delivery tab. In that GR Non-valuated checkbox might be checked.Generally for account assignment category asset it is ticked.
    If you tick GR non-valuated check box then at the time of GR accounting document will not be created.Accounting document will be created only at the time of IR.
    or
    Have you mantained Chart of accounts.
    have you mantained Valuation area settings
    Transaction event key
    Valuation class settings.
    Check your material master data in accounting view have mantained Valuation class.
    Check your back ground settings OMWN.

  • Getter method for Generic type in BinarySearchTree

    Hi, I had to write an implementation of a BinarySearchTree for an assignment.
    I have the two classes, one 'BinarySearchTree' which basicly just points to the root, and the node that does most of the work:
    public class BinaryNode<K extends Comparable<K>,V>
         public K _key;
         public V _val;
         private BinaryNode _left;
         private BinaryNode _right;
         public V getVal() //getter
              return _val;
    }In my BinarySearchTree class I use this getter method like so:
    V nodeValue;
    nodeValue = (V) oldNode.getVal();The thing I don't understand is why I have to cast the value returned? If I don't it won't compile!
    It is working fine as is, but my lecturer is always saying to avoid casts.
    Thanks,
    Austin.

    Your BinaryNode class looks OK.
    Could you post a small piece of code I can compile and run and results in the compile error you described? (Don't post the entire thing!)
    Thanks.

  • Query Builder - Getting Universelist for one specific Group

    Hi All,
               I am in need of a query string (in query builder) that will return me All the universes for a specific group.Is it possible to do and if possible what will be the way to do this?
    Thanks in advance for your help,
    Anirban

    Hi Anirban,
    What is the BusinessObjects version you are using ( i.e. BO XIR2 or BOXI 3.0)?
    Regards,
    Deepti Bajpai

  • Query to get total for missing Dates

    Hi All
    Please help in writing this query.
    I have a table with the below values
    Tx_code -- TX_date --- Amount -- Accumlated_amt
    101 -- 01-Jul-2011 -- 100 -- 100
    102 -- 01-Jul-2011 -- 300 -- 300
    103 -- 01-Jul-2011 -- 500 -- 500
    101 -- 02-Jul-2011 -- 150 -- 250
    103 -- 02-Jul-2011 -- 100 -- 600
    101 -- 03-Jul-2011 -- 250 -- 500
    103 -- 03-Jul-2011 -- 50 -- 650
    I want the output as below
    101 -- 01-Jul-2011 -- 100 -- 100
    102 -- 01-Jul-2011 -- 300 -- 300
    103 -- 01-Jul-2011 -- 500 -- 500
    101 -- 02-Jul-2011 -- 150 -- 250
    102 -- 02-Jul-2011 -- 0 -- 300
    103 -- 02-Jul-2011 -- 100 -- 600
    101 -- 03-Jul-2011 -- 250 -- 500
    102 -- 03-Jul-2011 -- 0 -- 300
    103 -- 03-Jul-2011 -- 50 -- 650
    For Tx_code 102 is available in 01-Jul-2011 but not in 02-Jul-2011 and 03-Jul-2011
    But i want this row in my output for all other dates.
    Below are my database version info
    Oracle Database 10g Release 10.2.0.1.0 - Production
    PL/SQL Release 10.2.0.1.0 - Production
    "CORE     10.2.0.1.0     Production"
    TNS for 32-bit Windows: Version 10.2.0.1.0 - Production
    NLSRTL Version 10.2.0.1.0 - Production
    Thanks
    Rak

    There you are:SQL>WITH t AS
      2       (SELECT 101 AS tx_code, TO_DATE('01-Jul-2011', 'DD-MON-YYYY') AS tx_date, 100 AS amount,
      3               100 AS accumlated_amt
      4          FROM DUAL
      5        UNION ALL
      6        SELECT 102, TO_DATE('01-Jul-2011', 'DD-MON-YYYY'), 300, 300
      7          FROM DUAL
      8        UNION ALL
      9        SELECT 103, TO_DATE('01-Jul-2011', 'DD-MON-YYYY'), 500, 500
    10          FROM DUAL
    11        UNION ALL
    12        SELECT 101, TO_DATE('02-Jul-2011', 'DD-MON-YYYY'), 150, 250
    13          FROM DUAL
    14        UNION ALL
    15        SELECT 103, TO_DATE('02-Jul-2011', 'DD-MON-YYYY'), 100, 600
    16          FROM DUAL
    17        UNION ALL
    18        SELECT 101, TO_DATE('03-Jul-2011', 'DD-MON-YYYY'), 250, 500
    19          FROM DUAL
    20        UNION ALL
    21        SELECT 103, TO_DATE('03-Jul-2011', 'DD-MON-YYYY'), 50, 650
    22          FROM DUAL)
    23  SELECT   c.tx_code AS tx_code, c.tx_date AS tx_date, NVL(t.amount, 0) AS amount,
    24           (SELECT MAX(t.accumlated_amt)KEEP (DENSE_RANK FIRST ORDER BY tx_date DESC)
    25              FROM t
    26             WHERE t.tx_code = c.tx_code AND t.tx_date <= c.tx_date) AS accumlated_amt
    27      FROM (SELECT b.tx_code, tx_date
    28              FROM (SELECT     a.min_date + LEVEL - 1 AS tx_date
    29                          FROM (SELECT MIN(tx_date) AS min_date, MAX(tx_date) AS max_date
    30                                  FROM t) a
    31                    CONNECT BY LEVEL <= max_date - min_date + 1) a,
    32                   (SELECT DISTINCT tx_code
    33                               FROM t) b) c,
    34           t
    35     WHERE t.tx_code(+) = c.tx_code AND t.tx_date(+) = c.tx_date
    36  ORDER BY c.tx_date, c.tx_code
    37  /
       TX_CODE TX_DATE       AMOUNT ACCUMLATED_AMT
           101 01-JUL-11        100            100
           102 01-JUL-11        300            300
           103 01-JUL-11        500            500
           101 02-JUL-11        150            250
           102 02-JUL-11          0            300
           103 02-JUL-11        100            600
           101 03-JUL-11        250            500
           102 03-JUL-11          0            300
           103 03-JUL-11         50            650Urs

  • Can I get iMessages for two Apple IDs on my phone?

    I have a work Apple ID and a personal Apple ID. I don't take my work iPad home, but co-workers need to send me messages after I've left for the day. Can I set up my work Apple ID on my iPhone? When I try to add it, it says it's already in use.

    Nope only one apple id can be used.

  • Sql query question - been trying for two days

    Hi guys im trying to carry out an sql query
    Im using a left join to do a query, which gives me a set of results:
    select COURSESTUDENT.StudentNo, COURSESTUDENT.CourseCode, COURSESTUDENT.Year, MARKS.ExamMark, MARKS.EntryNo FROM COURSESTUDENT LEFT JOIN MARKS ON COURSESTUDENT.StudentNo=MARKS.StudentNo AND COURSESTUDENT.CourseCode=MARKS.CourseCode AND COURSESTUDENT.Year=MARKS.Year
    but I would like to do a select on this result but do not want to use a create view as if more than one person access this page at a time then if the servlet tries to create the view an error will occur.
    I would like to do the following select statement on the results of the query above..
    select * from (above) where CourseCode='ELE304' AND Year=1999;
    Is this possible, im using postgres..
    Please help......
    thanks
    tzaf

    Sorry, I have never used postgres, but in several databases, the following syntax would work and provide the correct ResultSet.
    select *
    from (
         SELECT
             COURSESTUDENT.StudentNo,
             COURSESTUDENT.CourseCode,
             COURSESTUDENT.Year,
             MARKS.ExamMark,
             MARKS.EntryNo
         FROM
             COURSESTUDENT LEFT JOIN MARKS ON
             COURSESTUDENT.StudentNo=MARKS.StudentNo AND
             COURSESTUDENT.CourseCode=MARKS.CourseCode AND 
             COURSESTUDENT.Year=MARKS.Year
         ) A
    WHERE
        CourseCode='ELE304' AND
        Year=1999

Maybe you are looking for