Query return value

hi everybody
i join new project and here some query use in reports like this, bt i m confuse abt
ths query. that exact wht meaning of this query
plz help me
SELECT SUM(QTY),
SUM(val)
FROM (
SELECT
SUM(NVL(m.item_qty,0)) qty,
SUM(NVL(m.item_qty,0) * rate) VAL
FROM inv_m m
WHERE m.div_code = 'IND01'
AND m.inv_date BETWEEN TO_DATE('1-JAN-2006') AND TO_DATE('29-JUL-2006'))

It would give another result in the presence of NULLs with AVG aggregate for example.
DROP TABLE T1;
CREATE TABLE T1 AS
     SELECT
                DECODE(MOD(ROWNUM, 2), 0, OBJECT_ID, TO_NUMBER(NULL)) C1
               ,DECODE(MOD(ROWNUM, 2), 0, OBJECT_NAME, NULL) C2
          FROM USER_OBJECTS
          WHERE ROWNUM <= 10
SELECT * FROM T1;
    C1 C2
171692 ATT_EMP_LEAVES
28972 COUNTRIES
28977 DEPARTMENTS
28978 DEPT_ID_PK
28982 EMPLOYEES
10 rows selected.
COLUMN Count FOR 999
COLUMN SumC1 FOR 9999999
COLUMN MinC1 FOR 9999999
COLUMN MaxC1 FOR 9999999
COLUMN AvgC1 FOR 9999999.999
COLUMN StddevC1 FOR 9999999.999
COLUMN MinC2 FOR A15
COLUMN MaxC2 FOR A15
SELECT
           COUNT(*) Count
          ,SUM(C1)     SumC1
          ,MIN(C1)     MinC1     
          ,MAX(C1)     MaxC1
          ,AVG(C1)     AvgC1
          ,STDDEV(C1)     StddevC1
          ,MIN(C2)     MinC2
          ,MAX(C2)     MaxC2
     FROM T1;
COUNT    SUMC1    MINC1    MAXC1        AVGC1     STDDEVC1 MINC2           MAXC2
   10   287601    28972   171692    57520.200    63823.977 ATT_EMP_LEAVES  EMPLOYEES
SELECT
           COUNT(*) Count
          ,SUM(C1)     SumC1
          ,MIN(C1)     MinC1     
          ,MAX(C1)     MaxC1
          ,AVG(C1)     AvgC1
          ,STDDEV(C1)     StddevC1
          ,MIN(C2)     MinC2
          ,MAX(C2)     MaxC2
     FROM T1
     WHERE C1 IS NOT NULL
COUNT    SUMC1    MINC1    MAXC1        AVGC1     STDDEVC1 MINC2           MAXC2
    5   287601    28972   171692    57520.200    63823.977 ATT_EMP_LEAVES  EMPLOYEES
(SELECT
           SUM(C1)
          ,MIN(C1)
          ,MAX(C1)
          ,AVG(C1)
          ,STDDEV(C1)
          ,MIN(C2)
          ,MAX(C2)
     FROM T1
     WHERE C1 IS NOT NULL
MINUS
SELECT
           SUM(C1)
          ,MIN(C1)
          ,MAX(C1)
          ,AVG(C1)
          ,STDDEV(C1)
          ,MIN(C2)
          ,MAX(C2)
     FROM T1
UNION ALL
(SELECT
           SUM(C1)
          ,MIN(C1)
          ,MAX(C1)
          ,AVG(C1)
          ,STDDEV(C1)
          ,MIN(C2)
          ,MAX(C2)
     FROM T1
MINUS
SELECT
           SUM(C1)
          ,MIN(C1)
          ,MAX(C1)
          ,AVG(C1)
          ,STDDEV(C1)
          ,MIN(C2)
          ,MAX(C2)
     FROM T1
     WHERE C1 IS NOT NULL
no rows selectedCheers:o)

Similar Messages

  • Sys_refcursor not fetching any data although query returns value

    hi!!!
    I am using sys_refcursor to return columns,and using below procedure to do so.Although data is there in table_1 and table_2.
    PROCEDURE test_pro(abc_date N DATE,
    cur_get_data OUT sys_refcursor
    OPEN cur_get_data
    for
    select A.col1,B.col2
    from table_1 A
    where A.dis_date=abc_date
    left outer join
    table_2 B
    on
    A.dis_date=B.dis_date;
    IF cur_get_data%rowcount=0
    then
         raise e_error;
    END if;
    EXCEPTION
         when e_error
         then
              ------no_data_found;
         when others
         then
    --------(giving SQL error with error code);
    END      test_pro;
    while running below sql in sql window of pl/sql developer fetching
    data
    select A.col1,B.col2
    from table_1 A
    where A.dis_date=abc_date
    left outer join
    table_2 B
    on
    A.dis_date=B.dis_date;
    but while testing the test_pro in test window of pl/sql developer it is
    not fetching any data and raising e_error each time
    is there any problem arising using IF cur_get_data%rowcount=0 as each time it is going to exception block..
    so can somebody please put some ideas what cud be the possible reason for this??

    Welcome to the forum!
    Unfortunatley you posted to the wrong forum. This question belongs in the SQL and PL/SQL forum.
    PL/SQL
    >
    sys_refcursor not fetching any data although query returns value
    but while testing the test_pro in test window of pl/sql developer it is
    not fetching any data and raising e_error each time
    is there any problem arising using IF cur_get_data%rowcount=0 as each time it is going to exception block..
    >
    A cursor doesn't fetch data - your code has to do that. The code you posted doesn't have any FETCH statements so no data will be fetched.
    There is no problem using 'IF cur_get_data%rowcount=0' but it will always be 0 in your code because you are not fetching any data.
    I'm guessing that you are trying to determine if there are any rows for the query. That isn't going to work since a cursor doesn't fetch rows.
    You just have to return the cursor to the caller and the caller will have to perform at least one fetch to see if there are any rows.
    If the above answers your question the just mark the question ANSWERED. Otherwise, since you have posted in the wrong forum
    1. repost the question in the SQL and PL/SQL forum
    2. Edit this post to add a link to the new thread in the other forum
    3. Mark this question ANSWERED so people will follow up in the other forum.
    Thanks.

  • SQL Query returns values like "---" and "NA"

    Hi
              When I execute a sql query in MII it returns values like "---" and "NA" for empty Char and numeric fields respectively.
    I have checked the database and made sure that these fields does not have any value. This happens only when I run the query through MII. Can any one know how can we get rid of these values?
    Thanks in advance
    Shaji

    Shaji,
    MII sets those values as a default if it discovers null values in a query result. You can change this default behaviour in several ways.
    First, have a look at the document [Setting custom null values in XML|http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/70628af0-8ec4-2c10-7da2-f451e412dd8f?quicklink=index&overridelayout=true]. Then you may also use SQL functions like [NVL|http://www.techonthenet.com/oracle/functions/nvl.php] to change the value directly in the SQL query. You can also change the value inside the MII BLT to whatever you need.
    Michael

  • SQL query returns value but EXEC SQL Task fails to assign variable

    I have an execute SQL task to get an identifier from an Oracle database and assign it to a variable (the variable is used in subsequent query's where clauses to transfer the data to a SQL Server database). If I copy the query from the SSIS
    package to the Oracle SQL Developer interface and run the query; I get the expected single identifier. If I run the execute SQL task I get the error "[Execute SQL Task] Error: An error occurred while assigning a value to variable "VariableName":
    "Single Row result set is specified, but no rows were returned."
    I can create phony/simpler versions of the query that will return the wrong identifier that will successfully assign the value to the variable, so the problem isn't with the variable itself or the way the result set is set up in the task (Result
    Set/Single Row in the General panel; Result Name 0/VariableName in the Result Set panel).
    How can two queries that return a single value produce different results with respect to the variable assignment process?

    Perhaps you can trap (profile) the query in Oracle to see what it gets submitted,
    thing is this query
    select id from table where ProcessedStatusColumn is null and DateColumn = (sub select to get most recent date in table where ProcessedStatusColumn is null)
    is not guaranteed to return a value, you need a default returned in case the search failed e.g.
    select
    NVL(id, 0)
    from table where ProcessedStatusColumn is null and DateColumn =
    (sub select to get most recent date in table where
    ProcessedStatusColumn is null)
    Arthur My Blog

  • Why Doesn't Query Return Date Values On Eval Table?

    Using Oracle 11.2.0.1 with XMLType Secure File Table named Eval.
    An interesting situation is occurring when attempting to query. A couple of things are going on.
    These queries do not have registered schemas.
    1. This query works fine
    SELECT xmlcast(xmlquery('declare default element namespace "http://www.cigna.com/acme/domains/eval/2010/03";
    declare namespace ns7="http://www.cigna.com/acme/domains/derived/fact/2010/03";
    $p/eval/derivedFacts/ns7:derivedFact/ns7:defId' passing e.object_value AS "p" RETURNING CONTENT)
    AS varchar2(100)) "Definition ID"
    FROM eval e;When adding a condition in the query to get defId=52657, get all nulls - even though this record exists - see sample data below.
    SELECT xmlcast(xmlquery('declare default element namespace "http://www.cigna.com/acme/domains/eval/2010/03";
    declare namespace ns7="http://www.cigna.com/acme/domains/derived/fact/2010/03";
    $p/eval/derivedFacts/ns7:derivedFact[/ns7:defId=888]/ns7:defId' passing e.object_value AS "p" RETURNING CONTENT)
    AS varchar2(100)) "Definition ID"
    FROM eval e;
    <?xml version = '1.0' encoding = 'UTF-8' standalone = 'yes'?><eval createdById="1957" acmeMemberId="3df55bd8-b3a6-4ba3-85e7-e8a188b7b4ed" category="external" eval_dt="2012-02-11T23:45:10.266Z" evalId="876d4035-aaf9-4f09-ae40-43498ec4973b" xmlns="http://www.cigna.com/acme/domains/eval/2010/03" xmlns:ns2="http://www.cigna.com/acme/domains/derived/fact/2010/03" xmlns:ns3="http://www.cigna.com/acme/domains/common/2010/03">
       <derivedFacts>
          <ns2:derivedFact>
             <ns2:defId>52657</ns2:defId>
             <ns2:defUrn>urn:coderunner:Medical:Definition:DerivedFact:52657:1</ns2:defUrn>
             <ns2:factSource>CCDR Member</ns2:factSource>
             <ns2:origInferred_dt>2012-02-11T23:45:10.266Z</ns2:origInferred_dt>
             <ns2:factValue>
                <ns2:type>boolean</ns2:type>
                <ns2:value>true</ns2:value>
             </ns2:factValue>
          </ns2:derivedFact>
          <ns2:derivedFact>
             <ns2:defId>52600</ns2:defId>
             <ns2:defUrn>urn:coderunner:Medical:Definition:DerivedFact:52600:2</ns2:defUrn>
             <ns2:factSource>CCDR Member</ns2:factSource>
             <ns2:origInferred_dt>2012-02-11T23:45:10.266Z</ns2:origInferred_dt>
             <ns2:factValue>
                <ns2:type>string</ns2:type>
                <ns2:value>null</ns2:value>
             </ns2:factValue>
          </ns2:derivedFact>
          <ns2:derivedFact>
             <ns2:defId>52599</ns2:defId>
             <ns2:defUrn>urn:coderunner:Medical:Definition:DerivedFact:52599:1</ns2:defUrn>
             <ns2:factSource>CCDR Member</ns2:factSource>
             <ns2:origInferred_dt>2012-02-11T23:45:10.266Z</ns2:origInferred_dt>
             <ns2:factValue>
                <ns2:type>string</ns2:type>
                <ns2:value>INT</ns2:value>
             </ns2:factValue>
          </ns2:derivedFact>
          <ns2:derivedFact>
             <ns2:defId>51400</ns2:defId>
             <ns2:defUrn>urn:coderunner:Medical:Definition:DerivedFact:51400:1</ns2:defUrn>
             <ns2:factSource>CCDR Member</ns2:factSource>
             <ns2:origInferred_dt>2012-02-11T23:45:10.266Z</ns2:origInferred_dt>
             <ns2:factValue>
                <ns2:type>integer</ns2:type>
                <ns2:value>34</ns2:value>
             </ns2:factValue>
          </ns2:derivedFact>
          <ns2:derivedFact>
             <ns2:defId>52177</ns2:defId>
             <ns2:defUrn>urn:coderunner:Medical:Definition:DerivedFact:52177:3</ns2:defUrn>
             <ns2:factSource>CCDR Member</ns2:factSource>
             <ns2:origInferred_dt>2012-02-11T23:45:10.266Z</ns2:origInferred_dt>
             <ns2:factValue>
                <ns2:type>string</ns2:type>
                <ns2:value>null</ns2:value>
             </ns2:factValue>
          </ns2:derivedFact>
          <ns2:derivedFact>
             <ns2:defId>52075</ns2:defId>
             <ns2:defUrn>urn:coderunner:Medical:Definition:DerivedFact:52075:1</ns2:defUrn>
             <ns2:factSource>CCDR Member</ns2:factSource>
             <ns2:origInferred_dt>2012-02-11T23:45:10.266Z</ns2:origInferred_dt>
             <ns2:factValue>
                <ns2:type>string</ns2:type>
                <ns2:value>M</ns2:value>
             </ns2:factValue>
          </ns2:derivedFact>
          <ns2:derivedFact>
             <ns2:defId>51391</ns2:defId>
             <ns2:defUrn>urn:coderunner:Medical:Definition:DerivedFact:51391:1</ns2:defUrn>
             <ns2:factSource>CCDR Member</ns2:factSource>
             <ns2:origInferred_dt>2012-02-11T23:45:10.266Z</ns2:origInferred_dt>
             <ns2:factValue>
                <ns2:type>boolean</ns2:type>
                <ns2:value>true</ns2:value>
             </ns2:factValue>
          </ns2:derivedFact>
          <ns2:derivedFact>
             <ns2:defId>51473</ns2:defId>
             <ns2:defUrn>urn:coderunner:Medical:Definition:DerivedFact:51473:1</ns2:defUrn>
             <ns2:factSource>CCDR Product</ns2:factSource>
             <ns2:origInferred_dt>2012-02-11T23:45:10.266Z</ns2:origInferred_dt>
             <ns2:factValue>
                <ns2:type>date</ns2:type>
                <ns2:value>2011-01-01</ns2:value>
             </ns2:factValue>
          </ns2:derivedFact>
          <ns2:derivedFact>
             <ns2:defId>51474</ns2:defId>
             <ns2:defUrn>urn:coderunner:Medical:Definition:DerivedFact:51474:1</ns2:defUrn>
             <ns2:factSource>CCDR Product</ns2:factSource>
             <ns2:origInferred_dt>2012-02-11T23:45:10.266Z</ns2:origInferred_dt>
             <ns2:factValue>
                <ns2:type>date</ns2:type>
                <ns2:value>9999-12-31</ns2:value>
             </ns2:factValue>
          </ns2:derivedFact>
          <ns2:derivedFact>
             <ns2:defId>52151</ns2:defId>
             <ns2:defUrn>urn:coderunner:Medical:Definition:DerivedFact:52151:3</ns2:defUrn>
             <ns2:factSource>CCDR Product</ns2:factSource>
             <ns2:origInferred_dt>2012-02-11T23:45:10.266Z</ns2:origInferred_dt>
             <ns2:factValue>
                <ns2:type>boolean</ns2:type>
                <ns2:value>true</ns2:value>
             </ns2:factValue>
          </ns2:derivedFact>
          <ns2:derivedFact>
             <ns2:defId>51048</ns2:defId>
             <ns2:defUrn>urn:coderunner:Medical:Definition:DerivedFact:51048:5</ns2:defUrn>
             <ns2:factSource>CCDR ProfileFact</ns2:factSource>
             <ns2:origInferred_dt>2012-02-11T23:45:10.266Z</ns2:origInferred_dt>
             <ns2:factValue>
                <ns2:type>boolean</ns2:type>
                <ns2:value>true</ns2:value>
             </ns2:factValue>
          </ns2:derivedFact>
          <ns2:derivedFact>
             <ns2:defId>60380</ns2:defId>
             <ns2:defUrn>urn:coderunner:Medical:Definition:DerivedFact:60380:1</ns2:defUrn>
             <ns2:factSource>CCDR ProfileFact</ns2:factSource>
             <ns2:origInferred_dt>2012-02-11T23:45:10.266Z</ns2:origInferred_dt>
             <ns2:factValue>
                <ns2:type>boolean</ns2:type>
                <ns2:value>true</ns2:value>
             </ns2:factValue>
          </ns2:derivedFact>
       </derivedFacts>
    </eval>Seem to be missing something conceptually, as to why this is not working.
    2. When replacing defId with origInferred_dt and adjust for the datatype; the query returns all nulls
    SELECT xmlcast(xmlquery('declare default element namespace "http://www.cigna.com/acme/domains/eval/2010/03";
    declare namespace ns7="http://www.cigna.com/acme/domains/derived/fact/2010/03";
    $p/eval/derivedFacts/ns7:derivedFact/ns7:origInferred_dt' passing e.object_value AS "p" RETURNING CONTENT)
    AS TIMESTAMP WITH TIME ZONE) "Original Inferred Date"
    FROM croutreach.eval e;Same here, seem to be missing something conceptually...
    Ultimately hoping to get this query to correctly work:
    SELECT xmlcast(xmlquery('declare default element namespace "http://www.cigna.com/acme/domains/eval/2010/03";
    declare namespace ns7="http://www.cigna.com/acme/domains/derived/fact/2010/03";
    $p/eval/derivedFacts/ns7:derivedFact[/ns7:defId=52657]/ns7:origInferred_dt' passing e.object_value AS "p" RETURNING CONTENT)
    AS TIMESTAMP WITH TIME ZONE) "Original Inferred Date"
    FROM croutreach.eval e;Any assistance would be much appreciated to say the least! :)
    Regards,
    Rick Blanchard

    Hi Rick,
    Ultimately hoping to get this query to correctly work:
    SELECT xmlcast(xmlquery('declare default element namespace "http://www.cigna.com/acme/domains/eval/2010/03";
    declare namespace ns7="http://www.cigna.com/acme/domains/derived/fact/2010/03";
    $p/eval/derivedFacts/ns7:derivedFact[/ns7:defId=52657]/ns7:origInferred_dt' passing e.object_value AS "p" RETURNING CONTENT)
    AS TIMESTAMP WITH TIME ZONE) "Original Inferred Date"
    FROM croutreach.eval e;
    Remove the initial slash in the predicate [ns7:defId=...] :
    xmlcast(
      xmlquery(
        'declare default element namespace "http://www.cigna.com/acme/domains/eval/2010/03"; (::)
         declare namespace ns7="http://www.cigna.com/acme/domains/derived/fact/2010/03"; (::)
         $p/eval/derivedFacts/ns7:derivedFact[ns7:defId=52657]/ns7:origInferred_dt'
         passing e.object_value AS "p"
         RETURNING CONTENT
      AS TIMESTAMP WITH TIME ZONE
    ) "Original Inferred Date"

  • Create SP that returns value and at the same time displays query result in output window

    I would like create an SP which will return the records from the table and also return value to my c# client application.
    For Example:
    Select * from employee returns all the query results in output window.
    Now I want to create an SP
    Create procedure Test
    As
    Declare @ret int,
    Select * from employee
    set @ret = Select count(*) from employee
    if @ret > 0
    return 1
    else
    return 0
    The above algo should return 1 0r 0 to c# client application and at the same time display all employees in sql query output window.
    Can u pls help in this regard.

    The above algo should return 1 0r 0 to c# client application and at the same time display all employees in sql query output window.
    Why?  and No!
    Why?  Your procedure generates a resultset of some number of rows.  You check the resultset for the presence of rows to determine if "anything is there".  You don't need a separate value to tell you this.  Note that it helps
    to post tsql that is syntactically correct.   While we're at it, if you just need to know that rows exist there is no need to count them since that does more work than required.  Simply test for existence using the appropriately-named function
    "exists".  E.g., if exists (select * from dbo.employee). 
    No!  A stored procedure does not display anything anywhere.  The application which executes the procedures is responsible for the consumption of the resultset; it chooses what to do and what to display. 
    Lastly, do not get into the lazy habit of using the asterisk in your tsql code.  That is not best practice.  Along with that, you should also get into the following best practice habits:
    schema-qualify your objects (i.e., dbo.employee)
    terminate every statement - it will eventually be required.

  • Return value for Direct OBPM SQL Query in OBPM 10GR3

    Hi all,
    I use a direct SQL Query provided by OBPM 10GR3 in my automatic activity to select certain elements from the db. The query is as follows:-
    foreach (element in
    SELECT id FROM TESTTABLE WHERE requestId = 732 and status = 1 )
    // statements
    logMessage("-- The id is-->" +element.id);
    This only returns when the id is found in the db but returns nothing when not found in db?
    How can I always get a return value? atleast a true or false, so that I can put IF statements?
    Because if it returns nothing, the loop does not execute {}? So we cannot put something like:-
    foreach (element in
    SELECT id FROM TESTTABLE WHERE requestId = 732 and status = 1 )
    logMessage("-- The id is-->" +element.id);
    if(element.id == null)
    logMessage("-- Id Not Found -->" );
    else
    logMessage("-- Id Found -->");
    How can I always get a return value from my OBPM direct query ?
    Remember , I am not using DynamicSQL in this case?

    Hi,
    Set a Boolean flag value to False before the SQL query.
    Some thing like:
    boolean flag = false;
    foreach (element in
    SELECT id FROM TESTTABLE WHERE requestId = 732 and status = 1 )
    logMessage("-- The id is-->" +element.id);
    flag = true;
    if(flag) {
    logMessage("-- Id Found -->" );
    else
    logMessage("-- Id Not Found -->");
    Hope the above logic would work fine.
    Bibhu
    Edited by: Bibhuti Bhusan on Sep 2, 2011 11:48 AM

  • LOV query is invalid, a display and a return value are needed

    hello - i am having this issue and can't get around this when creating a popup LOV based on sql.
    below is LOV query. as you see the view has only two columns. I tried various ways by giving alias to columns in query but nothing works. What did I miss here?
    select description,inventory_item_id from xx_apex_inv_v
    1 error has occurred
    LOV query is invalid, a display and a return value are needed, the column names need to be different. If your query contains an in-line query, the first FROM clause in the SQL statement must not belong to the in-line query.

    Did you try it like this?
    select description d, inventory_item_id v from xx_apex_inv_v

  • SQL query returns varchar - default value type!!!

    On a field in my portal form there is a default value type of 'SQL query returns varchar', where can I put this sql to get a default value from a table?

    Hi again
    I have this code in 'additional pl/sql code' - '...before displaying the page'. But it comes up with an error when I run the form.
    declare
    prop_v varchar2(20);
    group_v varchar2(3);
    el1_v varchar2(3);
    blk varchar2(10) := 'DEFAULT';
    begin
    prop_v := p_session.get_value_as_varchar2(p_block_name=>'DEFAULT', p_attribute_name => 'l_property_p');
    group_v := p_session.get_value_as_varchar2(p_block_name=>'DEFAULT', p_attribute_name => 'l_group_p');
    select element_code
    into el1_v
    from eh_risk_element_detail
    where property_ref = prop_v
    and group_code = group_v
    and line_no = 1;
    p_session.set_value(p_block_name => blk, p_attribute_name => 'L_ELEMENT1_P', p_value => el1_v);
    end;
    Rich

  • How to Sort by the length of the returned value from a query.

    Hi,
    I was wondering if it is possible to sort by the length of the returned value from a query?
    For example if I want to get a list of people with the name 'Samuel', I would like to short by how short the length of the whole name is.
    Sort by length of the name in SQL
    Samuel Syda
    Samuel Indranaka
    Samuel Johnsons
    Samuel Longhenderson
    Thank you.

    Hi,
    Sorting is done by an ORDER BY clause at the end of the main query.
    In most cases, you can ORDER BY any expression, even f it is not in the SELECT clause.  In this case, it sounds like you just need:
    ORDER BY  LENGTH (name_column)
    I hope this answers your question.
    If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all the tables involved, and the results you want from that data.
    Post your query, using an ORDER BY clause like the one above, and point out where that query is producing the wrong results, and explain, using specific examples, how you get the right results from the given data in those places.
    Always say what version of Oracle you're using (e.g. 11.2.0.2.0).
    See the forum FAQ: https://forums.oracle.com/message/9362002

  • Percentage pie chart whose query return just one value

    Hi,
    I have a requirement which is to display a pie chart that shows the relative percentage of based on a particular row's values.
    Here the SQL query return just one value to generate the chart, however Apex is creating its own seemingly random value to draw the rest of the chart and dividing the region.
    Is there any way for Apex to take the single value that the query returns as a percentage and generate the chart by calculating the other value to be as (100 - queried value) and split the region in the chart accordingly.
    Of course one method is to store both the value that the query returns as well as 100 - that value in a table and then write the query in the chart that references both these values.. but I'd like to know if there is a way to go about it without storing this extra bit of information in a table
    Thanks!

    you create a hidden page item and populate with total value and percentile calculated value and use it in dial chart as querry.

  • SQL dynamic query returning (problem with list of value)

    Hi, I'm having trouble with my query. I want to make where statement based on my selectlist, but the problem is that I couldnt write the correct string in my where condition.
    :P61_STATUS has this following display, return value
    Bewerber     Bewerber     
    PRA_Kandidat     PRA_Kandidat          
    abgelehnt     abgelehnt          
    angenommen     angenommen          
    Thema     Thema     
    angemeldet     angemeldet          
    abgegeben     abgegeben          
    abgeschlossen     abgeschlossen          
    bestätigt     bestätigt
    DECLARE
      q varchar2(4000);
      list_betreuer htmldb_application_global.vc_arr2;
      list_semester htmldb_application_global.vc_arr2;
      list_status htmldb_application_global.vc_arr2;
    BEGIN
    -- variable to store the list
    list_betreuer := HTMLDB_UTIL.STRING_TO_TABLE(:P61_BETREUER);
    list_semester := HTMLDB_UTIL.STRING_TO_TABLE(:P61_SEMESTER);
    list_status := HTMLDB_UTIL.STRING_TO_TABLE(:P61_STATUS);
    -- Query begins
    q:= 'select p1.name, p1.vorname , a1.tel, a2.tel, ';
    q:= q||'ab.thema, ab.status, ab.typ, s.bezeichnung, p2.name ';
    q:= q||'from person p1, person p2, adresse a1, adresse a2, ';
    q:= q||'zuordnungp_a zpa1,zuordnungp_a zpa2, ';
    q:= q||'abschlussarbeit ab, semester s ';
    q:= q||'WHERE ab.SEMESTER = s.OBJECTID (+) ';
    q:= q||'AND ab.STUDENT = p1.OBJECTID (+) ';
    q:= q||'AND ab.BETREUER = p2.OBJECTID (+) ';
    q:= q||'and p1.objectid = zpa1.person (+) ';
    q:= q||'and zpa1.adresse  = a1.objectid (+) ';
    q:= q||'and zpa1.art (+)= ''Privat'' ';
    q:= q||'and p1.objectid = zpa2.person (+) ';
    q:= q||'and zpa2.adresse  = a2.objectid (+) ';
    q:= q||'and zpa2.art (+)= ''Geschäft'' ';
    -- Loop for betreuer list
    FOR i in 1..list_betreuer.count
    LOOP
        IF i = 1 THEN
        q:= q||'AND (ab.betreuer = '||list_betreuer(i);
        ELSE
        q:= q||' OR ab.betreuer  = '||list_betreuer(i);
        END IF;
    END LOOP; if (list_betreuer.count>0)THEN q:= q||')'; END IF;
      -- Loop for semester list
    FOR i in 1..list_semester.count
    LOOP
        IF i = 1 THEN
        q:= q||'AND (ab.semester = '||list_semester(i);
        ELSE
        q:= q||'OR ab.semester = '||list_semester(i);
        END IF;
    END LOOP; if (list_semester.count>0)THEN q:= q||')'; END IF;
    -- Loop for status list
    FOR i in 1..list_status.count
    LOOP
        IF i = 1 THEN
        q:= q||'AND (ab.status = '||list_status(i)||'';
        ELSE
        q:= q||'OR ab.status = '||list_status(i)||'';
        END IF;
    END LOOP; if (list_status.count>0)THEN q:= q||')'; END IF;
      htp.p(q);
    return q;
    END;result
    select p1.name, p1.vorname , a1.tel, a2.tel, ab.thema, ab.status, ab.typ, s.bezeichnung, p2.name from person p1, person p2, adresse a1, adresse a2, zuordnungp_a zpa1,zuordnungp_a zpa2, abschlussarbeit ab, semester s WHERE ab.SEMESTER = s.OBJECTID (+) AND ab.STUDENT = p1.OBJECTID (+) AND ab.BETREUER = p2.OBJECTID (+) and p1.objectid = zpa1.person (+) and zpa1.adresse = a1.objectid (+) and zpa1.art (+)= 'Privat' and p1.objectid = zpa2.person (+) and zpa2.adresse = a2.objectid (+) and zpa2.art (+)= 'Geschäft' AND (ab.status = abgegeben) the problem is in this statement
    q:= q||'AND (ab.status = '||list_status(i)||'';that statement produce this following statement
    ab.status = abgegebenbut what I need is this statement
    ab.status = 'abgegeben';how can I achieve this statement?
    thank you very much

    raitodn wrote:
    ah ok , I was confused with this q:= q||'AND (ab.status = '''||list_status(i)||'''';I think I get it now
    basically stop the string and write double quotes before the variable
    'AND (ab.status = ' + ''||list_status(i)||'' + ''No, more like "wherever I want a single quote within a string, I put two single quotes instead and that tells oracle it's a quote and not the end of the string".
    q:= q||'AND (ab.status = '''||list_status(i)||'''';
           ^                 ^^^                  ^^^^
           |                 |/|                  ||/|
           |                 | |                  || \-- single quote indicates end of string
           |                 | |                  ||
           |                 | |                  |\-- two quotes indicate a single quote required
           |                 | |                  |
           |                 | |                  \-- single quote to open a new string
           |                 | |
           |                 | \-- single quote indicates end of string
           |                 |
           |                 \-- two quotes indicate single quote required
           \-- Open String

  • Single query return multiple value

    Hi ALL,
    I have a sql query as below :
    select order_number,
    (select decode(hcp.contact_point_purpose,'ABC',hcp.email_address,'CDE',hcp.email_address,null)
    from hz_contact_points,
    hz_parties hz
    WHERE hz.party_id=hcp.owner_table_id) Email
    FROM oe_order_headers_all h
    WHERE h.order_number='102'
    Actually the problem i am facing is the inner select query is returning multiple row , so my main query is erroring out, i need to capture the multiple row.
    in the above example the inner decode statement returning two mail address, i need to capture that, but while executing the whole query it is erroring out as saying single query returns multiple values.
    please help me on this to capture multiple values
    Thanks

    >
    select order_number,
    (select decode(hcp.contact_point_purpose,'ABC',hcp.email_address,'CDE',hcp.email_address,null)
    from hz_contact_points,
    hz_parties hz
    WHERE hz.party_id=hcp.owner_table_id
    /* a join is missing here that points to table oe_order_headers_all h*/) Email
    FROM oe_order_headers_all h
    WHERE h.order_number='102'
    >
    I can see a join missing in your select sub query.
    However, if you you are still getting the single query return multiple value error then you need to replace the sql sub query
    select decode(hcp.contact_point_purpose,'ABC',hcp.email_address,'CDE',hcp.email_address,null)
    from hz_contact_points,
    hz_parties hz
    WHERE hz.party_id=hcp.owner_table_id)by decode(hcp.contact_point_purpose,'ABC',hcp.email_address,'CDE',hcp.email_address,null)
    and join the two tables in you main query..
    Regards
    Biju
    ED: Provide test script and your expected output to get what you want exacly!
    Edited by: biju2012 on Sep 7, 2012 12:06 AM

  • I need that this query return only one value

    Hi, please. I need your help. I have this query:
    SELECT c.charvalue "Comentario", max(pi.id) as "id" --into :gcpe_last_comment
    FROM twflprocessinstances pi, twfliprocessparameters c
    WHERE pi.id = c.iprocess_id
    AND c.param_id = 1002286
    AND c.charvalue IS NOT NULL
    AND pi.processdef_id = 1600
    AND to_number(pi.id) <> 3817940
    AND to_number(pi.seeparameter1) =80137377
    group by c.charvalue
    having max(pi.id)
    This query return 3 rows, but I need that this query return only one row. The row that this query should return is the row before at the max id. Thanks

    Mmmm...I don't get it.
    You might need to post some sample data and expected results.

  • How to pass multiple query string values using the same parameter in Query String (URL) Filter Web Part

    Hi,
    I want to pass multiple query string values using the same parameter in Query String (URL) Filter Web Part like mentioned below:
    http://server/pages/Default.aspx?Title=Arup&Title=Ratan
    But it always return those items whose "Title" value is "Arup". It is not returned any items whose "Title" is "Ratan".
    I have followed the
    http://office.microsoft.com/en-us/sharepointserver/HA102509991033.aspx#1
    Please suggest me.
    Thanks | Arup
    THanks! Arup R(MCTS)
    SucCeSS DoEs NOT MatTer.

    Hi DH, sorry for not being clear.
    It works when I create the connection from that web part that you want to be connected with the Query String Filter Web part. So let's say you created a web part page. Then you could connect a parameterized Excel Workbook to an Excel Web Access Web Part
    (or a Performance Point Dashboard etc.) and you insert it into your page and add
    a Query String Filter Web Part . Then you can connect them by editing the Query String Filter Web Part but also by editing the Excel Web Access Web Part. And only when I created from the latter it worked
    with multiple values for one parameter. If you have any more questions let me know. See you, Ingo

Maybe you are looking for

  • 64bit Vista on a macbook

    can i run the 64bit version of vista on my 1st gen macbook?

  • Why is the aspect ratio altered when viewing my sample PDF in Safari?

    I am wondering if everyone else is seeing my pdf with the apsect ration altered. It looks squished horizontally in Safari. Many creatives view my samples in Safari. I want to make sure they are viewing it correctly. It is a reflection on me otherwise

  • Multiple hero images from one thumb?

    Hello all, I have been trying to figure this out for a while and it's driving me crazy (In Muse). Normally when I click on a thumb in a slideshow it shows just one hero image of the thumb (which makes sense). But I really want to have it so that if y

  • Open item list

    Frnds Where can i generate the list of all the open items for particula GL A/c? I just want to look at all the open item for particular GL A/C Please get me a T-CODE for tht Thanks

  • Function module to Post picking quantity & PGI

    hi all, i want to post picking quantity and do PGI for the given delivery document . please let me know if there is any BAPI or function module to do that . thanks in advace, aswin.