Problem in making SQL Query

Hello All,
I have one problem regarding sql query.
I have one internal table which contains equnr and bis as fields. There are two database tables egerr and eastl. The structure for tables are as follows:
Fields for egerr:
equnr, bis, logiknr in which first two fields form key.
Field for eastl:
anlage, bis, logiknr in which all fields form primary key.
I want to select records from internal table which does not have record in eastl.
For the reference we can extract logiknr from egerr by using intarnal table and then use this logiknr to check entry in table eastl. but i want those equnr which are in internal table but not mapped in eastl.
I want the most efficient solution for this as there are many records.
Thanks..... and if you have any queries then let me know.
Jignesh.

hi,
as per ur statement, u want the field equnr which exists in the internal table but not in eastl. now for comparing with eastl u will need to check for all the three fields as they form the key...
get data from egerr for matching equnr and bis in your internal table
i.e. assuming ur table is itab  and itab_logiknr contains a single field logiknr
select logiknr from egerr
  into table itab_logiknr
  for all entries in itab
  where equnr eq itab-equnr
    and bis eq itab-bis.
now from this data (itab_egerr), compare the data with that in eastl for matching (or non matching) values of logiknr
assuming data from eastl lies in itab_eastl
select anlage bis logiknr from eastl into itab_eastl
for all entries in itab_logiknr
where logiknr eq itab_logiknr-logiknr.
for non matching entries u can select data from eastl which is not present in itab_eastl now....
(but mind you....since all fields of eastl form the key, u might not be getting the correct data) so if possible study ur scenario again and see if u can search the eastl table comparing all fields in the primary key)
try this....get back in case of any clarifications
hope it gives u some pointers...
regards,
PJ

Similar Messages

  • Problem writing a sql query for a select list based on a static LOV

    Hi,
    I have the following table...
    VALIDATIONS
    ID          Number     (PK)
    APP_ID          Number     
    REQUESTED     Date          
    APPROVED     Date          
    VALID_TIL     Date
    DEPT_ID          Number     (FK)
    I have a search form with the following field item variables...
    P11_DEPT_ID (select list based on dynamic LOV from depts table)
    P11_VALID (select list based on static Yes/No LOV)
    A report on the columns of the Validations table is shown based on the values in the search form. So far, my sql query for the report is...
    SELECT v.APP_ID,
    v.REQUESTED,
    v.APPROVED,
    v.VALID_TIL,
    d.DEPT
    FROM DEPTS d, VALIDATIONS v
    WHERE d.DEPT_ID = v.DEPT_ID(+)
    AND (d.DEPT_ID = :P11_DEPT_ID OR :P11_DEPT_ID = -1)
    This query works so far. My problem is that I don't know how to do a search based on the P11_VALID item - if 'yes' is selected, then the VALID_TIL date is still valid. If 'no' is selected then the VALID_TIL date has passed.
    Can anyone help me to extend my query to include this situation?
    Thanks.

    Hello !
    Let's have a look at my example:create table test
    id        number
    ,valid_til date
    insert into test values( 1, sysdate-3 );
    insert into test values( 2, sysdate-2 );
    insert into test values( 3, sysdate-1 );
    insert into test values( 4, sysdate );
    insert into test values( 5, sysdate+1 );
    insert into test values( 6, sysdate+2 );
    commit;
    select * from test;
    def til=yes
    select *
      from test
      where decode(sign(trunc(valid_til)-trunc(sysdate)),1,1,0,1,-1)
           =decode('&til','yes',1,-1);
    def til=no
    select *                                                                               
      from test                                                                            
      where decode(sign(trunc(valid_til)-trunc(sysdate)),1,1,0,1,-1)
           =decode('&til','yes',1,-1);  
    drop table test;  It's working fine, I've tested it.
    The above changes to my first idea I did because of time portion of the DATE datatype in Oracle and therefore the wrong result for today.
    For understandings:
    1.) TRUNC removes the time part of DATE
    2.) The difference of to date-values is the number of days between.
    3.) SIGN is the mathematical function and gives -1,0 or +1 according to an negative, zero or positiv argument.
    4.) DECODE is like an IF.
    Inspect your LOV for the returning values. According to my example they shoul be 'yes' and 'no'. If your values are different, you may have to modify the DECODE.
    Good luck,
    Heinz

  • Mapping Problem with Native SQL query

    My application uses a native SQL query to locate certain entities. It looks like this:
    SELECT UPLOADATTEMPTREF, STUDENTNUMBER, USERID, WORKITEMCODE, WORKITEMINSTURN, WORKITEMTITLE, MODULERUNCODE, STUDENTNAME, SUBMISSIONDEADLINE, UPLOADATTEMPTSERVERDATE, FILENAME, UPLOADCOMPLETESERVERDATE, NEWFILENAME, FILESIZE, FILEPATH, DOWNLOADSERVERDATE, MODULECODE, MODULETITLE
    FROM Submission_Attempt WHERE UPLOADATTEMPTREF IN (
    SELECT uploadAttemptRef FROM (" +<br /><br />                         "SELECT MAX(uploadAttemptRef) AS uploadAttemptRef, UserID, workItemInstUrn, " +<br /><br />                         "workItemCode FROM Submission_Attempt where workiteminsturn = ?1 " +<br /><br />                         "GROUP BY UserID, workItemInstUrn, workItemCode) Table1 ) " +<br /><br />                         "and uploadCompleteServerDate is not null;"<br />
    My expectation was that EclipseLink would be able to handle the mapping of the results to the entity quite happily. However, I get a NonSynchronizedVector of Objects - each Object representing one field of data.
    I need help with either:
    Converting the above SQL into JPQL so that I (hopefully) don't have to worry about the SQL or
    Understanding why this isn't working properly...
    Anyone able to help?
    Edited by: phunnimonkey on Nov 6, 2008 3:33 AM

    Never mind - the problem was to do with not specifying a class when creating the native query.

  • Problem executing a sql query in 10g environment

    Hi,
    I am having problem executing the following sql query in 10g environment. It works fine in 8i environment.
    I tried to_number(to_char) and it did not work.
    **A.APPL_ACTION_DT >= TO_CHAR("&v_strBeginStatusDate&", 'DD-MON-YYYY') AND A.APPL_ACTION_DT <= TO_CHAR("&v_strEndStatusDate&", 'DD-MON-YYYY')))**
    Any suggestions..
    --Pavan                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    I would be surprised if that worked in 8i as posted, although I no longer have 8i to test. You do not tell us the error message you are getting, but there are several things wrong with what you posted.
    First, the substitution variable requires only the & at the beginning, you have one on each end of your string, the one at the end will remain in the string that is passed to the database.
    Second, you cannot TO_CHAR a string with a date format as you are trying to do. The TO_CHAR function is overloaded and has two basic forms TO_CHAR(date, format_model) and TO_CHAR(number, format_model). Note that neither takes a string. It would appear that at least current versions of Oracle choose the second signature unless specifically passed a date datatype.
    SQL> select to_char('&h', 'dd-mon-yyyy') from dual;
    Enter value for h: 12
    old   1: select to_char('&h', 'dd-mon-yyyy') from dual
    new   1: select to_char('12', 'dd-mon-yyyy') from dual
    select to_char('12', 'dd-mon-yyyy') from dual
    ERROR at line 1:
    ORA-01481: invalid number format modelalthough I suspect that the error you are getting with your posted code is more likely to be ORA-01722: invalid number.
    Depending on the data type of appl_action_date, you are probably lokoing for TO_DATE instead of TO_CHAR.
    John

  • Problem creating an sql query with a parameter which is a list

    Hi,
    Im having a problem creating a certain SQL query.
    The query looks like this:
    SELECT gstock_id FROM germplasm_stock gps, germplasm gp WHERE gps.germplasm_id = gp.germplasm_id AND organism_id IN ($childList:VARCHAR).
    the organism_id field is of DECIMAL type.
    the parameter childList is actually a list of Id's, something like: 123,124,789
    and it is created dynamically by an other function, so I cant just put it there staticlly.
    I tried using the ARRAY type instead of VARCHAR, but that didn't work,
    anyone knows how can I give this query a parameter which is a list of numbers ?
    Thanks

    I have tried all the following options and the same issue occurs:
    EXEC dbo.uspGetSiteChanges @ChangeVersion = ?
    With Parameter: 0, @ChangeVersion, ChangeVersion
    EXEC dbo.uspGetSiteChanges ?
    With Parameter: 0, @ChangeVersion, ChangeVersion
    In my first data flow I use the following and it works on two OLE DB Sources:
    EXEC dbo.uspGetSiteChanges @ChangeVersion = ?
    With:
    In my second data flow task, I use the same command and parameter mappings and it fails, very strange.

  • Problem in executeQuery(SQL query sentence with a ' );

    for example:
    String strName="";
    //here strName is searching key value.
    String strQueryString="SELECT * FROM Authors WHERE name='" strName "'";
    ResultSet rs=st.executeQuery(strQueryString);
    if strName value is "yijun_lee",that will return all information which the name columns value is "yijun_lee" with SQL Query sentence SELECT * FROM Authors WHERE name='yijun_lee'
    but if strName value is "yijun ' lee",that value contains a '.that will error!
    how to do?
    thanks very much!

    You could parse <strName > and insert another ' for each '
    A concrete example would be SELECT * FROM Authors WHERE name='yijun '' lee'HTH

  • Problem with a SQL query involving dates

    I have a database with each task made by a developer in the company's systems, with 2 fields to determine the duration of the tasks: begin_date and end_date, both Dates. Now I have to make an SQL query returning the total of hours each one worked counting every task, so I'm using something like this (simplifying):
    select user_id, sum(end_date - begin_date)
    from task
    group by user_id
    but I get a weird fractional number. How do I do this query?

    What database are you using? Oracle?
    The weird fractional number is probably the difference between the dates in days. If you want it in hours, try multiplying it with 24.
    select user_id, sum(end_date - begin_date) * 24
    from task
    group by user_id

  • Problem writing a sql query

    I am a Java Developer and new to database.
    Database Table:
    Table 'Authors' with fields 'Author'(Varchar2), 'Code'(Varchar2), 'Id'(Varchar2 ~ Not a primary key, multiple records can have same value) and 'Date_Sequence'(Number). The possible values for 'Code' could be either 'Yes' or 'No'.
    Approach:
    I can select a list of authors, say AYES AUTHORS with code 'Yes' and a list of authors, say NOES AUTHORS with code 'No' from my web page.
    When I submit the request, I need to retrieve all the Id's, where AYES Authors voted 'Yes' and NOES Authors voted 'No'.
    I have come up with the following query:
    SELECT DISTINCT ID FROM AUTHORS WHERE AUTHOR IN ('my selected AYES list') AND CODE = 'Yes'
    INTERSECT
    SELECT DISTINCT ID FROM AUTHORS WHERE AUTHOR IN ('my selected NOES list') AND CODE = 'No'
    Problem:
    Now the problem here being, I have to retrieve the id's where the 'Date Sequence' is same for 'Yes' and 'No'. Not sure how to link the Date_Sequence for both the queries across the intersect clause. Any clue is highly appreciated.
    Thanks.

    Not sure if i understand what the logic behind it is, but try this..
    WITH AUTHORS AS (SELECT 'AYES1' AUTHOR, 'Yes' CODE, '1' ID, TRUNC(SYSDATE) DATE_SEQ FROM DUAL
                     UNION ALL
                     SELECT 'AYES2' AUTHOR, 'Yes' CODE, '2' ID, TRUNC(SYSDATE)-1 DATE_SEQ FROM DUAL
                     UNION ALL
                     SELECT 'AYES3' AUTHOR, 'No'  CODE, '3' ID, TRUNC(SYSDATE) DATE_SEQ FROM DUAL
                     UNION ALL
                     SELECT 'NOES1' AUTHOR, 'No' CODE, '1' ID,  TRUNC(SYSDATE) DATE_SEQ FROM DUAL
                     UNION ALL
                     SELECT 'NOES2' AUTHOR, 'No'  CODE, '2' ID, TRUNC(SYSDATE) DATE_SEQ FROM DUAL
    SELECT AYES.ID, AYES.DATE_SEQ
      FROM AUTHORS AYES,
           AUTHORS NOES
    WHERE AYES.AUTHOR IN ('AYES1', 'AYES2', 'AYES3') AND AYES.CODE='Yes'
       AND NOES.AUTHOR IN ('NOES1', 'NOES2', 'NOES3') AND NOES.CODE='No'
       AND AYES.ID=NOES.ID
       AND AYES.DATE_SEQ=NOES.DATE_SEQ
    ID         DATE_SEQ
    1          22.10.08
    SQL>

  • Problem in running sql query

    Hello ,
    I am using oracle 10g apex 3.2.
    I have assosiated 2 schema "vpmys and vp" with one workspace.
    In the application , i created a new page of report ,which is assosiated with one schema called "vp" and i wish to run this query
    select * from vpmys.t_devotees
    minus
    select * from vp.t_devotees
    Same database dmp is installed in both schema except that the no of rows may be more or less in one database.So first i need to know the added rows and what are they and then insert the same no of rows into another db.
    But this doesnt run in the application.
    But it runs in the SQL Command window.
    So what way i should change the query so that it runs.
    Thanks
    Swapna

    Post your question in Application Express Forum
    Oracle Application Express (APEX)

  • Making SQL Query dynamic

    hi ,
    I want to write a method that will take column-name and value to be searched parameters
    somehting like this
    void somemethodname(String colName , String tableName , String[] arr )
    i will read all the parameters value from XML file
    colName , tableName , arr
    WHERE string array will contain fields on which you want to use your WHERE clause
    SELECT EVENT_TYPE_ID from Register WHERE EVENT_TYPE = 'event_type_id' "
    Now in this query my column-name id EVENT_TYPE_ID
    whose value i want to find out
    basically i dont want to hardcode anything
    can somebody help me in doing this.
    Please post code if you have
    thanks in advance
    Nilesh

    This may give you some ideas. There is a lot more that needs to be done, such as check if value is numeric, string, date, etc. and put them in the sql accordingly.
    import java.util.*;
    class Test {
         public static void main(String[] args)  {
              String[][] s = {{"VAL1", "VAL1"}, {"VAL2", "VAL2"}};
              Test t = new Test();
              t.sql("column", "table", s, "VAL1");
         public void sql (String colName, String tableName, String[][] where, String orderBy) {
              StringBuffer sql = new StringBuffer();
              sql.append("Select ").append(colName)
                   .append(" From ").append(tableName)
                   .append(" Where ");
              for (int x=0; x<where.length; x++) {
                   sql.append(where[x][0]).append(" = '").append(where[x][1]).append("'");
                   if (x<where.length-1)
                        sql.append(" And ");
              if (orderBy != null)
                   sql.append(" Order By ").append(orderBy);
              System.out.println(sql.toString());
    }Hope this helps!
    DesQuite

  • Problem with the SQL Query

    Hey all,
    I made a view so that I could join three databases together and put the results on the association table. However, I keep getting an error that I'm not using the SELECT keyword, when I am. Maybe there is another bug somewhere else?
    CREATE OR REPLACE VIEW "SUPPLIER_COMPETENCY_VW" ("SUPPLIER_PK", "COMPETENCY_PK", "ROW_CREATE_EMAIL", "ROW_CREATE_TIMESTAMP", "ROW_UPDATE_EMAIL", "ROW_UPDATE_TIMESTAMP") AS
    SELECT
    SUPPLIER_COMPETENCY_VW.SUPPLIER_PK||'|'||SUPPLIER_COMPETENCY_VW.COMPETENCY_PK,
    SUPPLIER_COMPETENCY_VW.SUPPLIER_PK,
    SUPPLIER_COMPETENCY_VW.COMPETENCY_PK,
    SUPPLIER_COMPETENCY_VW.ROW_CREATE_EMAIL,
    SUPPLIER_COMPETENCY_VW.ROW_CREATE_TIMESTAMP,
    SUPPLIER_COMPETENCY_VW.ROW_UPDATE_EMAIL,
    SUPPLIER_COMPETENCY_VW.ROW_UPDATE_TIMESTAMP
    FROM
    SUPPLIER_COMPETENCY_TB, TPL_SUPPLIERS_TB, TPL_CONTACTS_TB
    WHERE
    TBL_SUPPLIER_TB.SUPPLIER_PK = SUPPLIER_COMPETENCY_TB.SUPPLIER_PK
    AND
    TBL_COMPETENCY_TB.COMPETENCY_PK = SUPPLIER_COMPETENCY_TB.SUPPLIER_PK
    Any Suggestions?
    Sumer

    CREATE VIEW "SUPPLIER_COMPETENCY_VW" ("SUPPLIER_PK", "COMPETENCY_PK", "ROW_CREATE_EMAIL", "ROW_CREATE_TIMESTAMP", "ROW_UPDATE_EMAIL", "ROW_UPDATE_TIMESTAMP") AS
    SELECT
    SUPPLIER_COMPETENCY_TB.SUPPLIER_PK||'|'||SUPPLIER_COMPETENCY_TB.COMPETENCY_PK,
    SUPPLIER_COMPETENCY_TB.SUPPLIER_PK,
    SUPPLIER_COMPETENCY_TB.COMPETENCY_PK,
    SUPPLIER_COMPETENCY_TB.ROW_CREATE_EMAIL,
    SUPPLIER_COMPETENCY_TB.ROW_CREATE_TIMESTAMP,
    SUPPLIER_COMPETENCY_TB.ROW_UPDATE_EMAIL,
    SUPPLIER_COMPETENCY_TB.ROW_UPDATE_TIMESTAMP
    FROM
    SUPPLIER_COMPETENCY_TB
    The same error keeps coming up of being unable to find the SELECT keyword, yet im not sure where the error is.
    Sumer

  • SQL query problem - select max (case... aggregate function)

    Hi,
    I have a problem with below sql query, it gives me problem/error message 'ORA-00937: not a single-group group function', why?
    select sag.afdeling, sag.sagsnr, to_char(sag.start_dato, 'yyyy-mm-dd'), sag.stat, BOGF_TRANS.TRANSTYPE,
    max (case when BOGF_TRANS.TRANSTYPE = 'K' then sum(bogf_trans.belobdkk) end) + -- as "TRANSTYPE K",
    max (case when BOGF_TRANS.TRANSTYPE = 'D' then sum(bogf_trans.belobdkk) end) as "TRANSTYPE K & D",
    max (case when BOGF_TRANS.TRANSTYPE = 'S' then sum(bogf_trans.belobdkk) end) as "SUM TRANSTYPE S"
    from sag
    join bogf_trans on sag.selskab = bogf_trans.selskab and sag.sagsnr = bogf_trans.sagsnr and sag.afdeling = bogf_trans.afdeling
    where SAG.SELSKAB=37 and SAG.AFDELING = 'SUS' AND SAG.SAGSNR = 10876
    group by sag.afdeling, sag.sagsnr, sag.start_dato, sag.stat, BOGF_TRANS.TRANSTYPE
    If I exclude (columns) as below it give me correct summations (max (case... sum(...)) but then I miss some important info that I need
    select
    max (case when BOGF_TRANS.TRANSTYPE = 'K' then sum(bogf_trans.belobdkk) end) + -- as "TRANSTYPE K",
    max (case when BOGF_TRANS.TRANSTYPE = 'D' then sum(bogf_trans.belobdkk) end) as "TRANSTYPE K & D",
    max (case when BOGF_TRANS.TRANSTYPE = 'S' then sum(bogf_trans.belobdkk) end) as "SUM TRANSTYPE S"
    from sag
    join bogf_trans on sag.selskab = bogf_trans.selskab and sag.sagsnr = bogf_trans.sagsnr and sag.afdeling = bogf_trans.afdeling
    where SAG.SELSKAB=37 and SAG.AFDELING = 'SUS' AND SAG.SAGSNR = 10876
    group by sag.afdeling, sag.sagsnr, sag.start_dato, sag.stat, BOGF_TRANS.TRANSTYPE
    Any ideas?

    Moved to more sutable forum, sorry.

  • Strange problem with SQL query in toad.

    Guys,
    My colleague is up with a strange problem with an SQL query that if it is run in toad encounters the "ORA-03113: end-of-file on communication channel" problem,but if run in SQL plus executes just fine.
    Do anyone have thoughts about this strange error in toad?
    Thanks!!!!
    Regards,
    Bhagat

    Not sure what version of TOAD you have but it may have shipped with SQLMonitor which montiors SQL sent from Windows apps . Navigation should be similar to;
    Start~Programs~Quest Software~TOAD for Oracle~Tools~SQLMonitor
    or
    C:\Program Files\Quest Software\Toad for Oracle\SQLMonitor.exe
    To use it, start TOAD and connect, start SQLMonitor and click the checkbox for TOAD.exe, then execute the query. SQLMonitor will show you the actual query that TOAD sent to the client. It may be exactly what you sent or it may contain some extras.

  • SQL Query for full paid invoices and payed out credit notes

    Hi alltogether,
    I have some problems with a sql query.
    I want to export all closed (full paid) invoices and credit notes in a table with the paid date.
    The problem is that I have several internal reconciliations for one invoice or credit note.
    So with my current query I get all these dates in the result but only for invoices, not for credit notes.
    I only need the last internal reconciliation date as payment date for all invoices and credit notes where the open amount is 0.
    In SAP B1 the finance team has service invoices and credit notes imported out of an ERP system.
    These documents are marked with an 'Y" in the coloumn "U_I_Imported" in the table "OINV" or "ORIN".
    SELECT
    OINV.DocTotal - OINV.PaidToDate as Offen, OINV.NumAtCard, OINV.U_I_Imported, ORCT.DocDate as 'Zahlungsdatum'
    SELECT
    OINV.DocTotal - OINV.PaidToDate as Offen, OINV.NumAtCard, OINV.U_I_Imported, ORCT.DocDate as 'Zahlungsdatum'
    FROM
    OJDT inner join
    ORCT on OJDT.BaseRef = ORCT.DocNum inner join
    RCT2 on ORCT.DocNum = RCT2.DocNum inner join
    OINV on RCT2.BaseAbs = OINV.DocEntry
    where
    OINV.DocTotal - OINV.PaidToDate = 0 and  OINV.U_I_Imported = 'Y'
    group by
    OINV.NumatCard, OINV.DocTotal - OINV.PaidToDate, OINV.U_I_Imported, ORCT.DocDate
    order by
    ORCT.DocDate
    I hope you can help me.
    Kind regards,
    Max

    The solution for my problem:
    select
    OINV.DocTotal - OINV.PaidToDate as 'Offen', OINV.CardCode as 'Kundennummer', OINV.NumAtCard as 'DIAMOD Rechnungsnummer', OINV.DocNum as 'Dokumentennummer',  max(ORCT.DocDate) as 'Zahlungsdatum', case when ORCT.DocCurr = (select MainCurncy from OADM) then RCT2.DcntSum else RCT2.DcntSumFC end as 'SkontoRechnungswährung',
        RCT2.DcntSum as 'SkontoFirmenwährung'
    from
        JDT1 inner join
        OJDT on JDT1.TransId = OJDT.TransId inner join
        ORCT on OJDT.BaseRef = ORCT.DocNum inner join
        RCT2 on ORCT.DocNum = RCT2.DocNum inner join
        OINV on RCT2.BaseAbs = OINV.DocEntry
    where
    JDT1.TransType in ('24') and
    OINV.U_I_Imported = 'Y' and
    OINV.DocTotal - OINV.PaidToDate = 0
    group by
    OINV.NumAtCard, OINV.DocNum, OINV.CardCode, OINV.DocTotal - OINV.PaidToDate, ORCT.DocCurr, RCT2.DcntSum, RCT2.DcntSumFC
    union all
    select
    OINV.DocTotal - OINV.PaidToDate as Offen, OINV.CardCode as 'Kundennummer', OINV.NumAtCard as 'DIAMOD Rechnungsnummer', OINV.DocNum as 'Dokumentennummer',  max(OITR.ReconDate) as 'Zahlungsdatum',
        0.0 as 'SkontoRechnungswährung',
        0.0 as 'SkontoFirmenwährung'
    from
    OITR inner join
    ITR1 on OITR.ReconNum = ITR1.ReconNum inner join
    OINV on ITR1.SrcObjAbs = OINV.DocEntry
    where
    OINV.DocTotal - OINV.PaidToDate = 0 and ITR1.SrcObjTyp = 13 and OINV.U_I_Imported = 'Y'
    group by
    OINV.NumatCard, OINV.DocNum, OINV.CardCode, OINV.DocTotal - OINV.PaidToDate
    union all
    select
    ORIN.DocTotal - ORIN.PaidToDate as Offen, ORIN.CardCode as 'Kundennummer', ORIN.NumAtCard as 'DIAMOD Rechnungsnummer', ORIN.DocNum as 'Dokumentennummer',  max(OITR.ReconDate) as 'Zahlungsdatum',
        0.0 as 'SkontoRechnungswährung',
        0.0 as 'SkontoFirmenwährung'
    from
    OITR inner join
    ITR1 on OITR.ReconNum = ITR1.ReconNum inner join
    ORIN on ITR1.SrcObjAbs = ORIN.DocEntry
    where
    ORIN.DocTotal - ORIN.PaidToDate = 0 and ITR1.SrcObjTyp = 14 and ORIN.U_I_Imported = 'Y'
    group by
    ORIN.NumatCard, ORIN.DocNum, ORIN.CardCode, ORIN.DocTotal - ORIN.PaidToDate

  • Regarding Exceptions of a SQL query

    Hi,
    We have a problem regarding the sql query shown below:
    select max(column1) into var1
    from table1
    where column2 = 100;
    We don't have any rows in the table1 but we are not getting the "NO data exception" while executing the query in a procedure.
    If we modify the query to
    select column1 into var1
    from table1
    where column2 = 100;
    then 'No data found' exception is raised.
    Can you please let us the reason behind this.
    Thanks in advance.
    Lakshmi

    Cut from Oracle documentation
    If a query with an aggregate function returns no rows or only rows with nulls for the argument to the aggregate function, the aggregate function returns null.
    AVG
    COUNT
    GROUPING
    MAX
    MIN
    STDDEV
    Aggregate function don't return 'No datafound Exception" I believe....Correcte me if i am Worng
    Ashok

Maybe you are looking for