Wrong record reterived by select query

Hi,
I am facing crictical problem in my select query.
select distinct a.name,
b.DESC_TEXT,
max(d.START_DT),max(d.ver_num)
from Siebel.S_PROD_INT a,
S_ISS_SUB_OBJ b,
S_VOD c,
s_vod_ver d
where
c.OBJECT_NUM=a.CFG_MODEL_ID
and c.Row_id=b.VOD_ID
and d.vod_id=c.Row_id
and d.VOD_id=b.VOD_id
and a.DESC_TEXT like '%CAP%'
and d.start_dt is not null and a.name like 'TSR9010492/32000%'
group by a.LAST_UPD,b.DESC_TEXT,a.desc_text,a.name
Actual Result (wrong):
Name, desc_text, start_dt, ver_num
TSR9010492/32000,    A190042010,      21-04-10,              3
TSR9010492/32000, A19042010, 21-04-10, 3
Expected Result:
Name, desc_text , start_dt, ver_num
TSR9010492/32000, A19042010, 21-04-10, 3
Above query reterived wrong version (2 version) record as mentioned Bold in actual result.
Please help me, let u know.
Thanks.
Edited by: user9522927 on Apr 21, 2010 2:10 AM

Hi,
Try to execute the below query and check logically (data residing in columns) makes the selections for both records
and make changes to ur query. As we can't know your DB information and we can predict..
select c.OBJECT_NUM,a.CFG_MODEL_ID,c.Row_id,b.VOD_ID,d.vod_id,b.VOD_id,d.start_dt,a.name
from      Siebel.S_PROD_INT a,
     S_ISS_SUB_OBJ b,
     S_VOD c,
     s_vod_ver d
where
     c.OBJECT_NUM=a.CFG_MODEL_ID
    and c.Row_id=b.VOD_ID
    and d.vod_id=c.Row_id
    and d.VOD_id=b.VOD_id
    and a.DESC_TEXT like '%CAP%'
    and d.start_dt is not null and a.name like 'TSR9010492/32000%'
    and a.name in ('TSR9010492/32000','TSR9010492/32000')HTH
- Pavan Kumar N
ORACLE 9i/10g - OCP
http://www.oracleinternals.blogspot.com

Similar Messages

  • Restricting record in the select query

    Is there any way to restrict the number of search (e.g 10) records in the SELECT query ?

    Hi,
    You can use as below:
    select <fieldname> up to 10 rows from <tablename> into itab.
    Thanks,
    Sriram Ponna.

  • Displaying different no. of  records for a select Query for the same dbuser

    Hi,
    While querying from my machine after connecting to custom schema it is displaying 3000 rows.
    When the same query was executed from different machine it is displaying just 31 records.
    1. Connect as xxyy user and executed the below command
    select count(*) from xxyy. XXYY_APAR_SUPP_CUST_MAST_V.
    output is showing some 3000 records
    2. Connect as xxto user and executed the below commands for a specific user and specific machine
    select count(*) from xxyy. XXYY_APAR_SUPP_CUST_MAST_V.
    output is showing just 31 records
    Please help...!!

    Hi,
    I hope you would have resolved the problem, if not, next step could be to check the TNS on both machines because now i suspect that your TNS on other machine points to some idfferent database.
    What do you mean by following
    2. Connect as xxto user and executed the below commands for a specific user and specific machineSo you connect with different users? If yes, then from both machines, if you connect with the same user, is result same?
    When the same query was executed from different machine it is displaying just 31 records.Please paste the TNs entry for the database from both of your client machines from where you run the query.
    Salman

  • Please explain this select query

    Hello Experts
    please see this select query.
      select  *  from kna1 where lifnr = '1111111101'.
    while debugging how to see what records this above select query has fetched. please explain me.
    Thanks for all the replies

    Hi madan,
    as explained, you need an ENDSELECT which I think you already have. In debugger, you could see the records fetched between SELECT and ENDSELECT but you will probably get a DUMP because a forbidden database access interrupt is detected.
    If your program does not process the records you have no chance to see them.
    A possible solution is:
    data:
      lt_kunnr type table of kna1-kunnr.
    select * from kna1 where lifnr = '1111111101'.
      append kna1-kunnr to lt_kunnr.
    endselect.
    Now you have the primary key KUNNR of all records fetched in table lt_kunnr.
    Regards,
    Clemens

  • What is the wrong with my select query

    HI All,
    TYPES: BEGIN OF t_equi,
             equnr          TYPE equi-equnr,
             aedat          TYPE equi-aedat,
             matnr          TYPE equi-matnr,
             sernr          TYPE equi-sernr,
             kunde          TYPE equi-kunde,
             zzreg_date     TYPE equi-zzreg_date,
             zzin_indic     TYPE equi-zzin_indic,
             zzinvoice_num  TYPE equi-zzinvoice_num,
             zzinvoice_date TYPE equi-zzinvoice_date,
             kund1          TYPE equz-kund1,
          END OF t_equi,
    DATA: it_equi        TYPE TABLE OF t_equi,
      SELECT equnr
             aedat
             matnr
             sernr
             kunde          "Ship to
             zzreg_date
             zzin_indic
             zzinvoice_num
             zzinvoice_date
             kund1            "Sold to
             INTO TABLE it_equi
             FROM equi AS a
             INNER JOIN equz AS b
             ON a~equnr = b~equnr
             WHERE a~equnr      IN s_equnr AND
    *               aedat GE gv_rdate AND
                   a~matnr      IN s_matnr AND
                   a~sernr      IN s_sernr AND
                   a~kunde      IN r_shpbr_kunde AND
                   a~zzin_indic IN s_indic  AND
                   b~datbi      EQ c_datbi  AND 
                   b~kund1     IN r_sldbr_kund1 .
    what is the wrong with this select query.. ?
    its giving me error  "The column name "EQUNR" is unclear ."
    Thanks

    Hi ,
    write  tablename or alias in select also
    SELECT a~equnr and check.
    Regards

  • How can we split a select query to 3 or 4 if it is fetching much records?

    I am running a query like:
    select * from table_name
    it will be fetching 152940696 records. Now i want to fetch this result as 3 or 4 select statements. That is, in the second query I want to fetch the records from where i stopped in the first query. and similar for the 3rd i have to continue from the 2nd query. And for the 4th query i have to start from where i have stopped in the 3rd query.
    when i tried with rownum we can fetch the records upto < or <= to a particular count like 100000000. But above this count i cannot fetch using rownum. Because > or >= wont work with rownum.
    Is there anyother way to split the select query as i explained.
    Thanks in advance

    I'll assume you want to split the query up for performance reasons.
    The easiest way to do this if you have the license is to use the parallel query option, which can help, hurt or do nothing. The only way to find out is to try. PQO would be best from a performance standpoint if possible, provided it will do what you need.
    Failing that as has been suggested you need a logical, scalable way to divide up the queries. It has already been pointed out that the rownum solution probably will not work correctly. Also, the MINUS with ROWNUM idea has the disadvantage of having to read a lot of the same data twice, making the query run longer.
    Perhaps a range would provide a way to split up the data - something like
    select whatever
      from table
    where primary_key < 10000000;
    select whatever
      from table
    where primary key between 10000001 and 199999999;
    ...

  • Select query on QALS table taking around 4 secs to fetch one record

    Hi,
    I have one select query that takes around 4 secs to fetch one record. I would like to know if there are any ways to reduce the time taken for this select.
    SELECT
         b~prueflos
         b~matnr
         b~lagortchrg
         a~vdatum
         a~kzart
         a~zaehler
         a~vcode
         a~vezeiterf
         FROM qals AS b LEFT OUTER JOIN qave AS a ON
         bprueflos = aprueflos
         INTO TABLE t_qals1
         FOR ALL ENTRIES IN t_lgorts
          WHERE  matnr = t_lgorts-matnr
          AND    werk = t_lgorts-werks
          AND    lagortchrg = t_lgorts-lgort
          AND    stat35 = c_x
          AND    art IN (c_01,c_08).
    When I took the SQL trace, here I found other details :
    Column          No.Of Distinct Records
    MANDANT                                      2
    MATNR                                      2.954
    WERK                                          30
    STAT34                                         2
    HERKUNFT                                   5
    Analyze Method                    Sample 114.654 Rows
    Levels of B-Tree                                 2
    Number of leaf blocks                         1.126
    Number of distinct keys                      16.224
    Average leaf blocks per key                1
    Average data blocks per key               3
    Clustering factor                                  61.610
    Also note, This select query is using INDEX RANGE SCAN QALS~D.
    All the suggestions are welcome
    Regards,
    Vijaya

    Hi Rob,
    Its strange but, the table t_lgorts  has only ONE record
    MATNR  =  000000000500003463
    WERK = D133
    LAGORTCHRG   = 0001                                            
    I have also seen that for the above criteria the table QALS has 2266 records that satisfy this condition.
    I am not sure..but if we write the above query as subquery instead of Outer join..will it improve the performance?
    Will check it from my side too..
    Regards,
    Vijaya

  • How to display a select query record in a tool tip?

    hi,
    How to display a select query record in a tool tip?
    for example i have a report employee. when i move the mouse pointer over a employee name, the tool tip should display the respective department id, department name...of that employee name.
    select dep_id, dep_name ....from department where employee.....Is it possible?
    thanks

    Dear Skud,
    Yes its possible..select ''||ename||'' from emp
    other wise you can use jQuery tooptip or some other JScript bundles.
    Thanks and Regards
    Maheswara

  • Select query for every 1000 records

    Hi all ,
             Please help me in the issue . I am using select query Select * from table up to 1000 rows for acheving the records but i want this process to retrigger once the process of 1000 records is compleded again it needs to fetch the next 1000 records and process the same . I am changing the status of the processed records once it is processed . Can can one tell me how to retrigger the select query once the 1000 records are processes.
    Thanks in advance,

    Hi Eric,
                  After selecting the 1000 records, find the key value of the last record. Build up the range as GT. Again use the select query.
    For example,
    Select * into table lt_data from ztab
    where key in r_key
    up to 1000 rows.
    regards,
    Niyaz

  • Select Query Fetching same records multiple time

    Hi ABAPers,
    I have an issue where the select query is fetching the same records more than one time for particular sale order.
    Kindly help to solve the issue.
    Thanks in advance..
    Here is the Select Query:-
    SELECT  VBAK~VKORG VBAK~VTWEG VBAK~VBELN VBAK~KUNNR
                   VBAK~ERDAT VBAK~LIFSK VBKD~INCO1 VBKD~INCO2
                   VBAP~MATNR VBAP~ARKTX VBAP~MATKL VBAK~BSTNK
                   VBAK~BSTDK VBAK~KNUMV VBAP~UEPOS VBAP~POSNR
                   VBAP~KWMENG VBAK~VDATU VBAP~VRKME VBAK~ERNAM VBAK~WAERK
      INTO CORRESPONDING FIELDS OF TABLE IT_PENDING FROM VBAK
      INNER JOIN VBAP ON VBAK~VBELN = VBAP~VBELN
      INNER JOIN VBKD ON VBAK~VBELN = VBKD~VBELN
      WHERE
      VBAK~VBELN IN SO_VBELN AND
      VBAK~ERDAT IN SO_ERDAT AND
      ( AUART EQ 'OR' OR AUART EQ 'ZEO' OR AUART EQ 'TA' OR AUART EQ 'LP' OR AUART EQ 'ZFOC' ) AND
      VKORG IN SO_VKORG AND
      VTWEG IN SO_VTWEG AND
      SPART IN SO_SPART AND
      KUNNR IN SO_KUNNR AND
      MATNR IN SO_MATNR AND
      MATKL IN SO_MATKL AND
      ABGRU EQ '' AND LIFSK <> '35'.
    Edited by: Suhas Saha on Jan 14, 2012 3:42 PM

    Hello Suhale,
    On retrospection, I found the query in my above response STILL HAS ONE ISSUE. When we are making a left outer join on vbkdposnr = vbapposnr we are only fetching vbkdinco1 and vbkdinco2 values where item level entries exist in VBKD which match with vbkdposnr = vbapposnr.
    Actually we should bring inco1 and inco2 from vbkd when a matching entry exists in vbkd where vbkdposnr = vbapposnr and if there is no entry matching vbkdposnr = vbapposnr, then we should fetch inc01 and inco2 from VBKD where posnr = '000000' (i.e., from header).
    This is how SAP behaves when you open an item in VA03 and look at inco1 and inco2. They come from the item if an entry corresponding to that item exists in VBKD otherwise they come from VBKD header record (where vbkd~posnr = '000000')
    We can't use VBKD in the joins and still be able to do the above. So we need to fetch inco1, inco2 from VBKD separately like below.
    FIELD-SYMBOLS: <fs_pending> LIKE LINE OF it_pending.
    SELECT vbak~vkorg vbak~vtweg vbak~vbeln vbak~kunnr
           vbak~erdat vbak~lifsk "vbkd~inco1 vbkd~inco2
           vbap~matnr vbap~arktx vbap~matkl vbak~bstnk
           vbak~bstdk vbak~knumv vbap~uepos vbap~posnr
           vbap~kwmeng vbak~vdatu vbap~vrkme vbak~ernam vbak~waerk
      INTO CORRESPONDING FIELDS OF TABLE it_pending
        FROM vbak INNER JOIN vbap
          ON vbak~vbeln = vbap~vbeln
            WHERE vbak~vbeln IN so_vbeln AND
                  vbak~erdat IN so_erdat AND
                ( vbak~auart EQ 'OR' OR vbak~auart EQ 'ZEO' OR
                  vbak~auart EQ 'TA' OR vbak~auart EQ 'LP' OR
                  vbak~auart EQ 'ZFOC' ) AND
                  vbak~vkorg IN so_vkorg AND
                  vbak~vtweg IN so_vtweg AND
                  vbak~spart IN so_spart AND
                  vbak~kunnr IN so_kunnr AND
                  vbap~matnr IN so_matnr AND
                  vbap~matkl IN so_matkl AND
                  vbap~abgru EQ '' AND
                  vbak~lifsk NE '35'.
      LOOP AT it_pending ASSIGNING <fs_pending>.
        SELECT SINGLE inco1 inco2
          FROM vbkd
            INTO (<fs_pending>-inco1,<fs_pending>-inco2)
              WHERE vbkd~vbeln = <fs_pending>-vbeln AND
                    vbkd~posnr = <fs_pending>-posnr.
        IF sy-subrc NE 0.
          SELECT SINGLE inco1 inco2
            FROM vbkd
              INTO (<fs_pending>-inco1, <fs_pending>-inco2)
                WHERE vbkd~vbeln = <fs_pending>-vbeln AND
                      vbkd~posnr = '000000'.
        ENDIF.
      ENDLOOP.
    Best regards,
    Vishnu Tallapragada.

  • Limit the records return by a select query

    I have select query as follows
    select id,name,designation from emlpoyyee;
    it is returning 20 rows.Is there any way to limit the records from a range to another range. eg -first 10 records. or 10-20 records e.t.c
    Thanks for any help

    For the case of first 10 or 20 row u can use
    select * from <table> where rownum <=<number>;
    select * from emp where rownum <=20;
    For the case of 10-20 record of something of range , there need to use partition on select as :
    select * from ( select <your_columnns1>, <your_columnns2>, row_number() over (partition by null order by null) sequence from <your_table>) where sequence between <lower_limit> and <upper_limit>;
    select * from ( select empno, empname row_number() over (partition by null order by null) sequence from emp) where sequence between 10 and 20;
    Try it and reply in case of any issue.

  • How to run select query from one SID to fetch record from another SID?

    I have two SID, one is AAA and another is BBB and the connection name is A1 and B1 respectively. I want to run one select query from A1 connection to fetch record B1. Can anyone help me how I can connect from one SID to another SID?

    Hi 869357,
    You can also use the copy command. (Works with limited types)
    try:
    help copyRegards,
    Turloch

  • Using varchar record in SELECT query

    Hi, from a VARCHAR field I get the string ",1,2,3,4,5,6,".
    I wish to use it in a SELECT query like:
    SELECT * FROM TABLE WHERE ID IN (1,2,3,4,5,6)
    Is there a way to obtain this in a tsql query ?
    Thank you
    Stefano

    CREATE TABLE t1
     col1 INT NOT NULL PRIMARY KEY,
     col2 VARCHAR(50) NOT NULL
    INSERT INTO t1 VALUES (1,'10,11,12')
    INSERT INTO t1 VALUES (2,'13')
    INSERT INTO t1 VALUES (3,'14,15')
    CREATE TABLE t2
     col1 INT NOT NULL PRIMARY KEY,
     col2 VARCHAR(50) NOT NULL
    INSERT INTO t2 VALUES (10,'A')
    INSERT INTO t2 VALUES (11,'B')
    INSERT INTO t2 VALUES (12,'C')
    INSERT INTO t2 VALUES (13,'D')
    INSERT INTO t2 VALUES (14,'E')
    INSERT INTO t2 VALUES (15,'F')
    SELECT DISTINCT O.col1, O.col2
    FROM t1 T
       INNER JOIN t2 O
          ON (PATINDEX('%,' + CAST(O.col1 AS varchar(10)) + ',%',
    Best Regards,Uri Dimant SQL Server MVP,
    http://sqlblog.com/blogs/uri_dimant/
    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting:
    Large scale of database and data cleansing
    Remote DBA Services:
    Improves MS SQL Database Performance
    SQL Server Integration Services:
    Business Intelligence

  • SELECT query & Database Table Difference in number of records

    Hi All,
    In program it’s selecting 3 records based on selection parameters whereas when i execute SE16 with same selection criteria gives 4 records.
    Please suggest when we will face these kind of issue
    Thanks,
    Spandana

    SELECT objnr wlges
    FROM bpge
    INTO TABLE t_bpge
    FOR ALL ENTRIES IN t_prps
    WHERE lednr  EQ c_0002
    AND      objnr  EQ t_prps-objnr
    AND      wrttp  EQ c_41.
    Here t_prps-objnr has the following values
    PR00473170
    PR00397060
    PR00397061
    PR00397062
    PR00397063
    PR00397064
    PR00397065
    For this selection criteria there are 4 records in BPGE table where as the program is fetching only 3

  • Is there a way to use owa_opt_lock.checksum in Select query that returns multiple records?

    Trying to do something as data would be uploaded and edited in grid. At present I am using Ora_Hash.
    SELECT
            e.ROWID, e.Employee_Id,e.First_Name,e.Last_Name,e.Email,e.Phone_Number,e.Hire_Date,
            e.Job_Id,e.Salary,e.Manager_Id,e.Department_Id,
            owa_opt_lock.checksum('HR','EMPLOYEES', e.rowid) As HashForThisRow
    FROM EMPLOYEES e;
    Thx

    No you can't.
    owa_opt_lock.checksum is a function which is used for optimist locking. It locks the row(probably by using Select FOR Update mechanism) which you select and which you are trying to update. As a result, what you are eventually trying to do is that inside a Select query you are using a function that is locking the rows, which is not allowed. And thus your query will fail with the below mentioned error.
    ORA-14551: cannot perform a DML operation inside a query
    ORA-06512: at "SYS.DBMS_SQL", line 1575
    ORA-06512: at "SYS.OWA_OPT_LOCK", line 172
    14551. 00000 -  "cannot perform a DML operation inside a query "
    *Cause:    DML operation like insert, update, delete or select-for-update
               cannot be performed inside a query or under a PDML slave.
    *Action:   Ensure that the offending DML operation is not performed or
               use an autonomous transaction to perform the DML operation within
               the query or PDML slave.
    Thanks,
    Ishan

Maybe you are looking for

  • Where did the "back-button listbox" go?

    It used to be (firefox 3.xx) that I could click a little arrow and choose to go back in my recent browsing history as many pages as I had viewed on the current tab. Now (firefox 4) I have to click back one at a time. How do I get the little listbox t

  • BAPI or FM for VL01N and Del. Packing

    Hello, I am looking for BAPI or FM to create delivery and to pack the del. items. Thank you,

  • Static reference error

    Hi experts, I have an application that launches a simple browser. I have this resourcheBundle containing the url string   ResourceBundle bundle = ResourceBundle.getBundle("Init");   String LOCAL_URL_STRING = bundle.getString("BrowseItem");The Resourc

  • Unable to access application deployed in OC4J server.

    All, I have hosted one small application in my local oc4j. I am able to access the application by giving the following. http://localhost:8888/<application> http://<hostname>:8888/<application> http://<IP address>:8888/<application> But others( from t

  • JMSBC application is not deploying

    Hi all, i am creating an bpel in which i am using an soap BC to pass input and get response, after that invoking an HL7BC after that i am using an JDBC BC to get result, then i am invoking an JMSBC which collects result from jdbc and then write it to