Query with wrong result

Hei
I have created a query, but when I made extraction, the invoice number occur many times, but it should only occur 1 time. The summation of the value it is also many times.
How do I get the Query made ​​so that the invoice  and amount only appears 1 time, if there is only one piece.
I assume that it is some markings, I have not been properly plugged.
BillT   Billing Type    Bill.Doc.     Rj     reason for rej.  Net Value   Curr.  BICat    Billing category  Doc. Date           Profit Ctr
S1      Cancel Inv     94902955                                     3480,00    DKK   L         Del.related bil       10.06.2009        1832
S1      Cancel Inv     94902955                                     3480,00    DKK   L         Del.related bil       10.06.2009        1832
S1      Cancel Inv     94902955                                     3480,00    DKK   L         Del.related bil       10.06.2009        1832
S1      Cancel Inv     94902955                                     3480,00    DKK   L         Del.related bil       10.06.2009        1832
                                                                                13920,00   DKK
I only need Bill.Doc and Net Value once.
Regards Lone
Edited by: Lone Holst on Aug 2, 2011 10:50 AM

Hi,
After you got the records/data in to the ITAB1.
assign ITAB1 to ITAB2.
sort: ITAB1, ITAB2 BY bill_doc.
delete adjaucent duplicates from ITAB2 comparing bill_doc.
loop at ITAB2.
loop at ITAB1 where bill_doc = ITAB2-BILL_DOC.
ITAB3-NET_VALUE = ITAB3-NET_VALUE + ITAB1-NETVALUE.
clear ITAB1.
endloop.
MOVE-CORRESPONDING ITAB1 to ITAB3.
append ITAB3.
clear: ITAB2, ITAB3.
ENDLOOP.
Ram.

Similar Messages

  • SQL Query with wrong result

    Hello.
    I have a query with LEFT OUTER JOIN that I think returns invalid results. Here are the problem details:
    CREATE TABLE DOGERR(
    IdDog INTEGER,
    SfPdg CHAR(1),
    IdVpl INTEGER,
    SfVpGot INTEGER,
    SfZrr CHAR(1)
    INSERT INTO DOGERR(IdDog, SfPdg, IdVpl, SfVpGot, SfZrr) VALUES (1, 'S', 1, 1, '7');
    INSERT INTO DOGERR(IdDog, SfPdg, IdVpl, SfVpGot, SfZrr) VALUES (2, 'S', 1, 1, '7');
    INSERT INTO DOGERR(IdDog, SfPdg, IdVpl, SfVpGot, SfZrr) VALUES (3, '$', 1, 2, 'C');
    COMMIT;
    CREATE UNIQUE INDEX DOGERR_PK ON DOGERR(IdDog);
    And now the query:
    SELECT D.IdDog, D.SfPdg, D.IdVpl, D.SfVpGot, D.SfZrr, T.IdVpl AS IdVplJoin, T.SfVpGot AS SfVpGotJoin, T.SfZrr AS SfZrrJoin
    FROM DOGERR D
    LEFT OUTER JOIN (SELECT * FROM DOGERR WHERE SfPdg = 'S' OR SfPdg = 'S') T ON
    T.IdVpl = D.IdVpl AND T.SfVpGot = D.SfVpGot AND T.SfZrr = D.SfZrr
    WHERE
    D.IdDog = 3
    AND D.SfVpGot = 2
    AND D.SfZrr = 'C';
    This query should (by my understanding) return only one row in wich the joined subquery columns should be NULL. And indeed query returns only one row on Oracle Database 10g Release 10.2.0.1.0 - Production and on Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production:
    IDDOG = 3, SFPDG = "$", IDVPL = 1, SFVPGOT = 2, SFZRR = "C", IDVPLJOIN = NULL, SFVPGOTJOIN = NULL, SFZRRJOIN = NULL
    But on Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - 64bit Production it returns TWO rows:
    IDDOG = 3, SFPDG = "$", IDVPL = 1, SFVPGOT = 2, SFZRR = "C", IDVPLJOIN = 1, SFVPGOTJOIN = 1, SFZRRJOIN = "7"
    IDDOG = 3, SFPDG = "$", IDVPL = 1, SFVPGOT = 2, SFZRR = "C", IDVPLJOIN = 1, SFVPGOTJOIN = 1, SFZRRJOIN = "7"
    And now the interesting part: any of the following modified versions of query works even on Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - 64bit Production, although modifications should not modify the result set:
    -- Removed unnecessary WHERE conditions
    SELECT D.IdDog, D.SfPdg, D.IdVpl, D.SfVpGot, D.SfZrr, T.IdVpl AS IdVplJoin, T.SfVpGot AS SfVpGotJoin, T.SfZrr AS SfZrrJoin
    FROM DOGERR D
    LEFT OUTER JOIN (SELECT * FROM DOGERR WHERE SfPdg = 'S' OR SfPdg = 'S') T ON
    T.IdVpl = D.IdVpl AND T.SfVpGot = D.SfVpGot AND T.SfZrr = D.SfZrr
    WHERE
    D.IdDog = 3;
    -- Removed unnecessary OR condition in subquery
    SELECT D.IdDog, D.SfPdg, D.IdVpl, D.SfVpGot, D.SfZrr, T.IdVpl AS IdVplJoin, T.SfVpGot AS SfVpGotJoin, T.SfZrr AS SfZrrJoin
    FROM DOGERR D
    LEFT OUTER JOIN (SELECT * FROM DOGERR WHERE SfPdg = 'S') T ON
    T.IdVpl = D.IdVpl AND T.SfVpGot = D.SfVpGot AND T.SfZrr = D.SfZrr
    WHERE
    D.IdDog = 3
    AND D.SfVpGot = 2
    AND D.SfZrr = 'C';
    -- Removed columns from joined subquery from SELECT part
    SELECT D.IdDog, D.SfPdg, D.IdVpl, D.SfVpGot, D.SfZrr, T.IdVpl AS IdVplJoin, T.SfVpGot AS SfVpGotJoin
    FROM DOGERR D
    LEFT OUTER JOIN (SELECT * FROM DOGERR WHERE SfPdg = 'S' OR SfPdg = 'S') T ON
    T.IdVpl = D.IdVpl AND T.SfVpGot = D.SfVpGot AND T.SfZrr = D.SfZrr
    WHERE
    D.IdDog = 3
    AND D.SfVpGot = 2
    AND D.SfZrr = 'C';
    NOTE: the query itself is a little stupid but this is just to demonstrate the problem. We have faced this problem at a customer with our real-world query.
    So, my question is: why different results ?
    Thanks.
    David

    hi,
    welcome to the forum,
    don't have a solution, but I thought I'd let you know that the first SQL statement only returns 1 row on 10gR2
    SQL> SELECT D.IdDog, D.SfPdg, D.IdVpl, D.SfVpGot, D.SfZrr, T.IdVpl AS IdVplJoin, T.SfVpGot AS SfVpGo
    tJoin, T.SfZrr AS SfZrrJoin
      2  FROM DOGERR D
      3  LEFT OUTER JOIN (SELECT * FROM DOGERR WHERE SfPdg = 'S' OR SfPdg = 'S') T ON
      4  T.IdVpl = D.IdVpl AND T.SfVpGot = D.SfVpGot AND T.SfZrr = D.SfZrr
      5  WHERE
      6  D.IdDog = 3
      7  AND D.SfVpGot = 2
      8  AND D.SfZrr = 'C';
         IDDOG S      IDVPL    SFVPGOT S  IDVPLJOIN SFVPGOTJOIN S
             3 $          1          2 C
    SQL> select * from v$version;
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
    PL/SQL Release 10.2.0.4.0 - Production
    CORE    10.2.0.4.0      Production
    TNS for Solaris: Version 10.2.0.4.0 - Production
    NLSRTL Version 10.2.0.4.0 - Production

  • Query giving wrong results

    Below is the query thats giving me wrong results ...can anyone help me figure where i am going wrong :(
    SQL> select count(*) from t where source='LP1.1';
      COUNT(*)
            69
    SQL> select count(*) from tblspring where line_a='LP1.1';
      COUNT(*)
           233now when i join these two table ...the total counts exceeds the expected records that i want
    SQL> select count(*) from t , tblspring where t.source=tblspring.line_a and t.source='LP1.1';
      COUNT(*)
         16077

    the thing is i want to filter only those records from table t where the column named  - source is equal to the column named line_a from table tblspring from the query in table t i get 69 records ....
    now when i match the it table tblspring with the condition
    i want the number of records should be less than or equal to 69 but not more than 69
    Edited by: Suhail Faraaz on Mar 5, 2011 7:31 AM

  • Query returning wrong results - Help required.

    Hi All,
    I am having a query in which I have 10 records, 5 with stop time 1 and 5 with stop time 2.
    I have a scenario in which, I need to calculate the maximum,minimum for the records
    with stop time 1 and 2.
    What I did is, I selected all the 10 records using for loop. Within the loop
    I am trying to find the maximum and minimum. It is giving me wrong results.
    Please help me. My code is follows
    declare
         v_p1_min_stop_tm     number;
         v_p1_max_stop_tm     number;
         v_p2_min_stop_tm     number;
         v_p2_max_stop_tm     number;
    begin
         for i in(
              select
                   stop_tm
              from
                   sample_stop
              where
                   map_nbr = 16645 and
                   stop_dt = '05-sep-08'
         )loop
              if i.stop_tm = 1 then
                   select
                        min(i.stop_tm),
                        max(i.stop_tm)
                   into
                        v_p1_min_stop_tm,
                        v_p1_max_stop_tm
                   from
                        dual;
              elsif i.stop_tm = 2 then
                   select
                        min(i.stop_tm),
                        max(i.stop_tm)
                   into
                        v_p2_min_stop_tm,
                        v_p2_max_stop_tm
                   from
                        dual;
              end if;
         end loop;
         dbms_output.put_line('minimum p1 stop time : '|| v_p1_min_stop_tm);
         dbms_output.put_line('maximum p1 stop time : '|| v_p1_max_stop_tm);
         dbms_output.put_line('minimum p2 stop time : '|| v_p2_min_stop_tm);
         dbms_output.put_line('maximum p2 stop time : '|| v_p2_max_stop_tm);
    end;
    My o/p is :
    Minimum P1 stop time : 523
    Maximum P1 stop time : 523
    Minimum P2 stop time : 719
    Maximum P2 stop time : 719
    Here how can I make the data as two sets, one set with stop time 1 and
    other with stop time 2.
    Regards
    Raghu

    If the data type of stop_tm is varchar then try following
    declare
         v_p1_min_stop_tm number;
         v_p1_max_stop_tm number;
         v_p2_min_stop_tm number;
         v_p2_max_stop_tm number;
    begin
         for i in(select  stop_tm  from  sample_stop
              where
                   map_nbr = 16645 and
                   stop_dt = '05-sep-08'
              )loop
         if i.stop_tm = 1 then
              select min(to_number(i.stop_tm)), max(to_number(i.stop_tm))
                   into v_p1_min_stop_tm,v_p1_max_stop_tm
              from
                   dual;
         elsif i.stop_tm = 2 then
              select
                   min(to_number(i.stop_tm)),     max(to_number(i.stop_tm))
                   into
                   v_p2_min_stop_tm,v_p2_max_stop_tm
              from
                   dual;
         end if;
    end loop;
    dbms_output.put_line('minimum p1 stop time : '|| v_p1_min_stop_tm);
    dbms_output.put_line('maximum p1 stop time : '|| v_p1_max_stop_tm);
    dbms_output.put_line('minimum p2 stop time : '|| v_p2_min_stop_tm);
    dbms_output.put_line('maximum p2 stop time : '|| v_p2_max_stop_tm);
    end;
    / Regards
    Singh

  • How to Transpose the Query with following result

    Dear All,
    Can anyone tell me a method of transposing my result of the following query
    Details can be found at
    http://obiee11ge.blogspot.com/2010/07/how-to-transpose-query-with-following.html
    Regards
    Mustafa

    Hi,
    Try this
    Create a combined request with,
    criteria 1 : Dummy, Revenue (Actual),Cogs(Actual), Opex(Actual), PL(Actual)
    in the dummy column fx enter the value as 'Actual'
    criteria 2 : Dummy, Revenue (Yago),Cogs(YAgo), Opex(Yago), PL(Yago)
    in the dummy column fx enter the value as 'Yago'
    criteria 3 : Dummy,Revenue (Budget),Cogs(Budget), Opex(Budget), PL(Budget)
    in the dummy column fx enter the value as 'Budget'
    Now go to the result columns and set the coumn names (Revenue, Cogs, Opex, PL) for the result set.
    For the Dumny remove the column heading.
    In table view you will get the result.
    Thanks,
    Vino

  • Query giving wrong result

    Hi
    Could anybody tell me why this query is giving the wrong result? The column 'Spend for Selected Period' is showing as far too much (ie exactly 11 times too much!!!) when totalling the 37 invoices involved
    SELECT T0.[CardCode], T0.[CardName],T0.[MailCity] AS 'Town', T2.[SlpName] AS 'Rep',
    SUM(T1.DocTotal - T1.VatSum)  AS 'Spend for Selected Period', MAX(T3.CreateDate) AS 'Last Visit Date'
    FROM OCRD T0  left JOIN OINV T1 ON T0.CardCode = T1.CardCode LEFT JOIN OSLP T2 ON T0.SlpCode = T2.SlpCode LEFT JOIN OSCL T3 ON T0.CardCode = T3.Customer
    where  T0.[CardCode] = 'wyk027/34' AND T1.DocDate BETWEEN '20090101' AND '20091231'
    GROUP BY T0.[CardCode], T0.[CardName],T0.[MailCity], T2.[SlpName]
    Thanks
    Steve

    Hi ,
    It seems like it is duplicated by the number of service calls.
    Try this one:
    SELECT T0.CardCode, T0.CardName,T0.MailCity AS 'Town', T2.SlpName AS 'Rep',
    SUM(T1.DocTotal - T1.VatSum) AS 'Spend for Selected Period', (select MAX(T3.CreateDate) from OSCL T3 where T0.CardCode = T3.Customer) AS 'Last Visit Date'
    FROM OCRD T0 inner JOIN OINV T1 ON T0.CardCode = T1.CardCode inner JOIN OSLP T2 ON T0.SlpCode = T2.SlpCode
    where T0.CardCode = '10001' AND T1.DocDate BETWEEN '20090101' AND '20091231'
    GROUP BY T0.CardCode, T0.CardName,T0.MailCity, T2.SlpName
    Best regards,
    Maya

  • Error executing a query with large result set

    Dear all,
    after executing a query which uses key figures with exception aggregation the BIA-server log (TrexIndexServerAlert_....trc) displays the following messages:
    2009-09-29 10:59:00.433 e QMediator    QueryMediator.cpp(00324) : 6952; Error executing physical plan: AttributeEngine: not enough memory.;in executor::Executor in cube: bwp_v_tl_c02
    2009-09-29 10:59:00.434 e SERVER_TRACE TRexApiSearch.cpp(05162) : IndexID: bwp_v_tl_c02, QueryMediator failed executing query, reason: Error executing physical plan: AttributeEngine: not enough memory.;in executor::Executor in cube: bwp_v_tl_c02
    --> Does anyone know what this message exactly means? - I fear that the BIA-Installation is running out of physical memory, but I appreciate any other opinion.
    - Package Wise Read (SAP Note 1157582) does not solve the problem as the error message is not: "AggregateCalculator returning out of memory with hash table size..."
    - To get an impression of the data amount I had a look at table RSDDSTAT_OLAP of a query with less amount of data:
       Selected rows      : 50.000.000 (Event 9011)
       Transferred rows :   4.800.000 (Event 9010)
    It is possible to calculate the number of cells retreived from one index by multiplying the number of records from table RSDDSTAT_OLAP by the number of key figures from the query. In my example it is only one key figure so 4.800.000 are passed to the analytical engine.
    --> Is there a possibility to find this figure in some kind of statistic table? This would be helpful for complex queries.
    I am looking forward to your replies,
    Best regards
    Bjoern

    Hi Björn,
    I recommend you to upgrade to rev 52 or 53. Rev. 49 is really stable but there are some bugs in it and if you use BW SP >= 17 you can use some features.
    Please refer to this thread , you shouldn't´t use more than 50% (the other 50% are for reporting) of your memory, therefor I have stolen this quote from Vitaliy:
    The idea is that data all together for all of your BIA Indexes does not consume more then 50% of total RAM of active blades (page memory cannot be counted!).
    The simpliest test is during a period when no one is using the accelerator, remove all indexes (including temporary) from main memory of the BWA, and then load all indexes for all InfoCubes into ain memory. Then check your RAM utilization.
    Regards,
    -Vitaliy
    Regards,
    Jens

  • Query gives wrong result

    Hello
    I need to derive result as mentioned below. In case of time range overlap, minimum of start time and maximum of end time should retrived.
    day               start_time     end_time
    sun               6:00                    6:15
    sun               6:30                    6:45
    sun               6:45                    7:00
    sun               7:00                    7:15
    mon               6:00                    6:15
    mon               7:00                    8:00
    o/p
    day          start_time     end_time
    sun          6:00                         6:15
    sun          6:30                         7:15
    mon          6:00                         6:15
    mon          7:00                         8:00
    We have tried with below query
    SELECT DISTINCT ctry_code emp_nbr, day, start_time,
                    end_time,               
                    (case when end_time = (LEAD (start_time) OVER (PARTITION BY ctry_code, emp_nbr, day ORDER BY ctry_code,
                             emp_nbr,
                             day,
                             start_time
                             )) then
                             'N'                      
                            else
                            'Y'
                     end) take_not               
               FROM sales_man
              WHERE emp_nbr = 230
           ORDER BY day, start_time
    From above query we have found below result which is incorrect.
    day          start_time            end_time
    sun          6:00          6:30
    sun          6:45          7:00
    sun          7:00          7:15
    mon          6:00          6:15
    mon          7:00          8:00Please help on this
    Thanks in advance

    Like this perhaps?
    SQL> ed
    Wrote file afiedt.buf
      1  with t as (select 'sun' as day, '6:00' as start_time, '6:15' as end_time from dual union all
      2             select 'sun', '6:30', '6:45' from dual union all
      3             select 'sun', '6:45', '7:00' from dual union all
      4             select 'sun', '7:00', '7:15' from dual union all
      5             select 'mon', '6:00', '6:15' from dual union all
      6             select 'mon', '7:00', '8:00' from dual)
      7  --
      8  -- end of test data
      9  --
    10  select day
    11        ,max(decode(tm,1,time)) as start_time
    12        ,max(decode(tm,2,time)) as end_time
    13  from (
    14        select day, time
    15              ,round((row_number() over (partition by day order by to_date(lpad(time,5,'0'),'hh24:mi'))+0.5)/2) as rn
    16              ,2-mod(row_number() over (partition by day order by to_date(lpad(time,5,'0'),'hh24:mi')),2) as tm
    17        from (
    18                    select day, decode(rn,1,start_time,end_time) as time
    19              from t cross join (select rownum rn from dual connect by rownum <= 2)
    20              group by day, decode(rn,1,start_time,end_time)
    21              having count(*) = 1
    22             )
    23       )
    24  group by day, rn
    25* order by day, rn
    SQL> /
    DAY STAR END_
    mon 6:00 6:15
    mon 7:00 8:00
    sun 6:00 6:15
    sun 6:30 7:15
    SQL>Obviously the ordering of the days in the result is based on the alphabetic name so "mon" comes before "sun", but you could change that easy enough like this...
    SQL> ed
    Wrote file afiedt.buf
      1  with t as (select 'sun' as day, '6:00' as start_time, '6:15' as end_time from dual union all
      2             select 'sun', '6:30', '6:45' from dual union all
      3             select 'sun', '6:45', '7:00' from dual union all
      4             select 'sun', '7:00', '7:15' from dual union all
      5             select 'mon', '6:00', '6:15' from dual union all
      6             select 'mon', '7:00', '8:00' from dual)
      7  --
      8  -- end of test data
      9  --
    10  select day
    11        ,max(decode(tm,1,time)) as start_time
    12        ,max(decode(tm,2,time)) as end_time
    13  from (
    14        select day, time
    15              ,round((row_number() over (partition by day order by to_date(lpad(time,5,'0'),'hh24:mi'))+0.5)/2) as rn
    16              ,2-mod(row_number() over (partition by day order by to_date(lpad(time,5,'0'),'hh24:mi')),2) as tm
    17        from (
    18                    select day, decode(rn,1,start_time,end_time) as time
    19              from t cross join (select rownum rn from dual connect by rownum <= 2)
    20              group by day, decode(rn,1,start_time,end_time)
    21              having count(*) = 1
    22             )
    23       )
    24  group by day, rn
    25  order by decode(day,'sun',1,'mon',2,'tue',3,'wed',4,'thu',5,'fri',6,'sat',7)
    26*      ,rn
    SQL> /
    DAY STAR END_
    sun 6:00 6:15
    sun 6:30 7:15
    mon 6:00 6:15
    mon 7:00 8:00

  • Query returning wrong result set

    I am running the following query on 8.1.7 database. The query is
    SELECT Y.*, TEVStatus.lEndStatusFlag ENDSTATUSFLAG
    FROM
    (SELECT ROWNUM RANK, X.* FROM (SELECT lExceptionID ID,
    TEVException.sMonitorName MONNAME, sExcpStatus STATUS
    FROM TEVException WHERE (TEVException.lExceptionID IN
    (SELECT lExceptionID FROM TEVException WHERE
    sUserName_AssignedTo = 'vadmin')) ORDER BY
    TEVException.lExceptionID DESC) X)
    Y, TEVStatus WHERE (Y.RANK > 0 AND Y.RANK < 0 + 51 + 1) AND
    (STATUS = TEVStatus.sStatusName);
    The result is
    RANK ID MONNAME STATUS ENDSTATUSFLAG
    51 29 Type09B Open 0
    50 30 Type09A Open 0
    49 31 Type09E Open 0
    48 32 Type09F Open 0
    47 33 Type09G Open 0
    46 34 Type09I Open 0
    45 35 Type09C Open 0
    44 36 Type10A Open 0
    43 37 Type04A Open 0
    39 41 Type08A Open 0
    38 42 Type08C Open 0
    RANK ID MONNAME STATUS ENDSTATUSFLAG
    37 43 Type10B Open 0
    36 44 Type10E Open 0
    35 45 Type10C Open 0
    34 46 Type10F Open 0
    33 47 Type10D Open 0
    32 48 Type08B Open 0
    31 49 Type04B Open 0
    29 51 Type08D Open 0
    28 52 Type11E Open 0
    27 53 Type11A Open 0
    26 54 Type11D Open 0
    RANK ID MONNAME STATUS ENDSTATUSFLAG
    25 55 Type11C Open 0
    24 56 Type11B Open 0
    23 57 Type12A Open 0
    22 58 Type12B Open 0
    21 59 Type12C Open 0
    20 60 Type12E Open 0
    19 61 Type12A Open 0
    18 62 Type12B Open 0
    17 63 Type12E Open 0
    16 64 Type12C Open 0
    15 65 Type12D Open 0
    RANK ID MONNAME STATUS ENDSTATUSFLAG
    14 66 Type12D Open 0
    4 80 Type01A_Ravi Open 0
    3 83 Type01A_Ravi Open 0
    2 84 Type01A_Ravi Open 0
    1 87 Type01A_Ravi Open 0
    42 38 Type06E Closed 8500
    41 39 Type06A Closed 8500
    40 40 Type06B Closed 8500
    30 50 Type06C Closed 8500
    13 68 Type01A Closed 8500
    12 69 Type01A Closed 8500
    RANK ID MONNAME STATUS ENDSTATUSFLAG
    11 70 Type01A Closed 8500
    10 71 Type01A Closed 8500
    9 72 Type01A Closed 8500
    8 73 Type01A Closed 8500
    7 75 Type01A Closed 8500
    6 77 Type01A Closed 8500
    5 78 Type01A Closed 8500
    51 rows selected.
    In the above result, the RANK is not sorted properly and I
    expected ID in descending order. The table which I was querying
    had only about 100 records. I ran the same query on a larger
    record set and the result is fine. I get ID in descending order
    which I was expecting.
    Could someone please tell me whether any bug in this case or
    something wrong in the query

    Hi...
    Took a quick look at tour SQL and....
      SELECT Y.*
           , TEVStatus.lEndStatusFlag ENDSTATUSFLAG
        FROM ( SELECT ROWNUM RANK
                    , X.*
                 FROM ( SELECT lExceptionID ID
                             , TEVException.sMonitorName MONNAME
                             , sExcpStatus STATUS
                          FROM TEVException
                         WHERE ( TEVException.lExceptionID IN
                                 ( SELECT lExceptionID
                                      FROM TEVException
                                    WHERE sUserName_AssignedTo
                                          = 'vadmin'
                         ORDER BY TEVException.lExceptionID DESC
                      ) X
             ) Y
           , TEVStat us
       WHERE ( Y.RANK > 0
               AND
               Y.RANK < 0 + 51 + 1
         AND STATUS = TEVStatus.sStatusName ;
    Should "FROM ( SELECT ROWNUM RANK" be "FROM ( SELECT ROWNUM,
    RANK"?
    RANK is a reserved word, an analytic function.
    Is "ORDER BY TEVException.lExceptionID DESC" doing anything?  I
    would drop it..
    Hope this helps. Good Luck.

  • Display a query with multiple results and a little addon :D

    Hello everybody,
    I wanna make a JSP page that displays multiple results from a query.
    I wanna those results to appair in a table, a row each one, and also a little "square radio form buttton" that makes me select rows I wanna delete (with another button at the end)
    any idea?
    Better if you post the code, I'm not a good JSP writer
    thanks everybody for your attention and your time
    Kind regards

    You're right.. I'd post nothing..
    But it's all still in progress and I don't know what to post..
    I understand is really difficult to invent some code without an origin (variables, functions, the bean), but also some general info would be really appreciated,also making a streched example if you can..
    REQUESTS:
    1) I need make a new JSP page, where will be visualize rows returned from a precise query selection
    2)I use Beans, and my idea was to create Bean in JSP, open connection, make the query and create "some kind of FOR cycle" that fills a table, row by row
    3)Every row must got a little "radio button" for a delete selection; the delete function will start when I press a specific button in this page(i'll use a servlet for this function)
    4)The biggest and important trouble is HOW to display multiple rows in the Table

  • Union_all query returns wrong results

    I have 6 individual queries that combine together using "union_all". If I run it, it returns 6084 records, see example 1.
    Example 1:
    sql1
    union_all
    sql2
    unionl_all
    sql3
    sql6;
    if I do it this way, example2, I get only 3821 records. Is there a bug in Oracle 11g? I select everything from 6084 records, I should get them all, correct?
    Example 2:
    select * from
    sql1
    union_all
    sql2
    unionl_all
    sql3
    sql6
    note that I use "union_all" because the computer does not take it without the underscore.

    user557594 wrote:
    Your queries do not deal with thousand of rows. My queries worked ok before the upgrade to 11g. I just want to know if there is a bug related to union all in 11g.If you believe that you are encountering a bug, you really should be posting this over on Metalink (My Oracle Support). When you do, you'll want to specify at a minimum the 4 digit Oracle version you are using (11g could mean either of two major releases and a few different patchsets).
    I'm sure if you search My Oracle Support, you'll find at least one bug in whatever version of 11g you're using that occurs when UNION ALL is used (though I'll wager that you need two or three other conditions to be true as well). If you open a ticket, however, Oracle Support can determine whether you are actually encountering an error and/or whether you've encountered any of the published bugs, an unpublished bug, or a new bug. Once you know that, Oracle Support may or may not have a patch for you.
    Unfortunately, if you can't post a test case that would allow us to reproduce the problem locally, it's going to be hard for us to provide much assistance. Of course, Oracle Support will also need a reproducible test case, but they can probably help you work through the process of putting one together complete with sample data and a query plan.
    Justin

  • Simple query returns wrong results in Sql 2012

    On my Windows 8 box running Sql 2012 11.0.3128, this query returns an IncludeCount of 0 and an ExcludeCount of 1.
    On my Windows 7 box running Sql 2008 10.50.2550 this query returns an IncludeCount of 3 and an ExcludeCount of 1, which is correct.
    In short, it runs properly on these versions of OS and Sql's:
    Windows 2008 R2 + Sql 10.50.2550
    Windows 2008 R2 + Sql 10.50.4000
    Windows 2012 SP1 + Sql 11.0.3000
    Windows 7 + Sql 11.0.2100
    And gives incorrect results on these OS's and Sql's (so far, tested):
    Windows 8 Enterprise + Sql 11.0.3128
    Windows 2008 R2 + Sql 10.50.2550
    I wondered if anyone else can reproduce this?  I can't figure out the magic combination of OS and SQL version this breaks on.
    In all scenarios, the resulting @filters table is populated correctly, and the [Include] column is properly set to a 1 or a 0, so why aren't the other variables being properly set?
    If I change the [ID] column to NONCLUSTERED, it works fine, too.  It doesn't matter if @filters is a TVP or a temp table or an actual table, same (incorrect) results in each case.
    DECLARE @filters TABLE([ID] bigint PRIMARY KEY, [Include] bit)
    DECLARE @excludecount int = 0
    DECLARE @includecount int = 0
    DECLARE @id bigint
    INSERT INTO @filters ([ID])
    VALUES (1), (3), (4), (-7)
    UPDATE @filters SET
        @id = [ID],
        @includecount = @includecount + (CASE WHEN @id > 0 THEN 1 ELSE 0 END),
        @excludecount = @excludecount + (CASE WHEN @id < 0 THEN 1 ELSE 0 END),
        [Include] = CASE WHEN @id > 0 THEN 1 ELSE 0 END,
        [ID] = ABS(@id)
    SELECT @includecount as IncludeCount, @excludecount as ExcludeCount
    SELECT * FROM @filters

    What part is undocumented?
    http://technet.microsoft.com/en-us/library/ms177523.aspx
    The above link states I can update variables inside an UPDATE statement ...
    But it does not say what the correct result of what you are trying to would be. Variable assignment in UPDATE only makes sense if the UPDATE hits one row. If the UPDATE matches several rows, which value you the variable is set to is not defined.
    It gets even more complicated when you have the variable on both sides of the expression. But I'd say that the only two values that makes as the final value of @includecount 0. An UPDATE statement, like other DML statements in SQL, is logically defined
    as all-at-once. There are no intermediate results. Therefore the only possible values are the initial value of @includecount plus the value of the CASE statement, which always should returns 0, since @id is NULL when the UPDATE statement starts to execute.
    I'm afraid that what you have is nonsense from a language perspective, and the result is undefined. Whenever you get different results from a query depending on whether you have certain indexes in place, you know that the query is indeterministic. There
    are certainly part of SQL that are indeterministic, for instance ORDER BY on a non-unique columns. But in this particular case you have also wandered out into the land that is also undefined.
    I'm not sure what you are trying to achieve, but I can only advice you to go back to the drawing board.
    Erland Sommarskog, SQL Server MVP, [email protected]

  • Query with Collapsing Result

    Dear Experts,
    I hope I am now on the right place upon my problem.
    I am generating a query in which I wanted to have a collapsing/expanding result based on the group by from the Document number of Journal entry. But the result I got is on the screenshot below.
    I boxed the doc num of JE = 100646, this is the sample doc that I wanted to have the group by function.
    here is my query:
    SELECT
        T4.Code,
        T0.DocDate as 'Date',
        T0.DocNum,
        T2.DocNum as 'AR Doc.#',
        T0.CardCode as BPCode,
        T3.CardName as BPName,
        T3.Address,
        T0.CounterRef as 'Ref',
        T0.TransId As 'Transaction No.',
        T3.LicTradNum as TIN,
        T1.Debit
    FROM dbo.ORCT AS T0
        LEFT join JDT1 T1 ON T0.DocNum = T1.BaseRef
        LEFT JOIN OINV t2 ON t0.DocNum = t2.ReceiptNum
           LEFT JOIN OCRD T3 ON T0.CardCode = T3.CardCode
           LEFT JOIN OFPR T4 ON T0.FinncPriod = T4.AbsEntry
           Inner JOIN OACT T5 on T1.Account = T5.AcctCode
           where T1.Account='_SYS00000000301' and t4.Code=[%]
    The result that I wanted to have is just like from the incoming payments form where it has that collapsing/expanding result for the purpose of Excel transfer and to return one value for the debit only as per one Journal entry.

    Hi Ramoncito,
    You can group easily in Crystal Report.
    Please try to Create this Report in Crystal.
    Thanks'
    Regards::::
    Atul Chakraborty

  • Simple XMLTABLE query with unexpected results

    I have the following (simplified) query. I have formatted the XML for easy reading in this message but there is no whitespace in the actual query.
    Can anyone tell me why I am receiving no records returned. Expecting one record with the value of 'REJECT'
    Thanks in advance.
    select a.decision
        from XMLTABLE(xmlnamespaces('http://schemas.xmlsoap.org/soap/envelope/' as "soap"
                                  , 'urn:schemas-cybersource-com:transaction-data-1.28' as "c")
                   , '/soap:Envelope/soap:Body/c:ReplyMessage'
          PASSING xmltype.createxml('
    <?xml version="1.0" encoding="utf-8" ?>
    <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
      <soap:Header>
       <wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
        <wsu:Timestamp xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="Timestamp-27593971">
         <wsu:Created>2009-06-15T17:49:02.870Z</wsu:Created>
        </wsu:Timestamp>
       </wsse:Security>
      </soap:Header>
      <soap:Body>
       <c:replyMessage xmlns:c="urn:schemas-cybersource-com:transaction-data-1.28">
        <c:merchantReferenceCode>27-0</c:merchantReferenceCode>
        <c:requestID>2450881422960008402433</c:requestID>
        <c:decision>REJECT</c:decision>
        <c:reasonCode>520</c:reasonCode>
        <c:requestToken>Ahj77wSRCbmf6bYuaSwCIJsfFx1osBTY+LjrRekDpt6POYI0kyro9JLBWBORCbmf6bYuaSwCAAAALQX8</c:requestToken>
        <c:purchaseTotals>
         <c:currency>USD</c:currency>
        </c:purchaseTotals>
        <c:ccAuthReply>
         <c:reasonCode>520</c:reasonCode>
         <c:amount>99.50</c:amount>
         <c:authorizationCode>123456</c:authorizationCode>
         <c:avsCode>Y</c:avsCode>
         <c:avsCodeRaw>YYY</c:avsCodeRaw>
         <c:cvCode/>
         <c:cvCodeRaw/>
         <c:authorizedDateTime>2009-06-15T17:49:02Z</c:authorizedDateTime>
         <c:processorResponse>A</c:processorResponse>
        </c:ccAuthReply>
       </c:replyMessage>
      </soap:Body>
    </soap:Envelope>')
          COLUMNS
            decision varchar2(30) PATH '/c:ReplyMessage/c:decision') aScott

    i think that the problem was in
    '/c:replyMessage/c:decision' and not '/c:ReplyMessage/c:decision'
    and
    '/soap:Envelope/soap:Body/c:replyMessage' not '/soap:Envelope/soap:Body/c:ReplyMessage'
    try
    Bye
    Maurizio

  • Mysql query with duplicate results

    I have a db that someone else set up that I am querying. It
    should have been set up to use a couple of different tables... one
    for clients and one for subclients with foreign keys to identify.
    However, each row has both the client and subclient which means
    there are duplicate clients since a single client may have several
    subclients.
    So...
    My query returns multiple clients where I need only one. I am
    guessing I can handle this in a loop with AS2.0 but I can't figure
    out how to tell when a unique client is detected. Does this make
    sense? Do I need to set my query up differently?

    try {
    ResultSet rs = DB.exQuery("SELECT max(transaction_date) as lastest_date, transaction_value,transaction_type"
                                  + "FROM transaction_log WHERE user_id =" + user.getId() + " AND is_credit = '1'");
    if ( rs.next () ) {can you explain
    *     trans_date = rs.getString("lastest_date");* // trans_date is a string type or date type... and max(transaction_date) as lastest_date returns which type...
         credit = rs.getString("transaction_value");
         trans_method = rs.getString("transaction_type");
    } catch(SQLException ex) {}

Maybe you are looking for

  • FrontRow leaves its Apps laying around when finished - why is this ?

    I've notice that after using FrontRow and returning to normal desktop that the various Apps such as iTunes, iTunes and iMovie are left around as inactive Apps rather than being properly terminated. Also the FrontRow App is left around and not termina

  • How can I transfer an e book from ADE to calibre and then to a sony ereader on a Mac

    Hi, I've read the past forums on this and I'm still having a real problem. I've got a Mac, my ADE is version 1.7 and my Sony reader is a 505. I can download an ebook into ADE but I can't get it into calibre to add it to my Sony, everytime I try an dr

  • Warning message every time I open an app

    I ended a Creative Cloud subscription and then opened another one because I got a free year from one of my employers.  Since the new subscription, I've been getting messages every time I open an application saying that Adobe is having trouble verifyi

  • フォトブラウザ写真整理について(Photoshop Album Mini 3.0)

    フォトブラウザで表示される写真の配置(順序)を自由に変えることは出来ないのでしょうか?(ドラッグドロップなどの方法で-) 解決方法を知っている方がいらっしゃったらアドバイスをお願いします. よろしくお願いいたします.

  • Outbound del: handling unit creates pack item

    Hi, I want in the delivery an extra line when I create a handling unit. Is this just one setting in customizing? I know I have to create packing instructions and a verp material, but I want to know how to activate the extra 9000 line with the packing