Use of where invoice.num = (select max( invoice.num).....

Post Author: Aron Sereny
CA Forum: Data Connectivity and SQL
i want to limit the result set of the select to only the latest invoice for a given client.
so, I was hoping to use use
invoice.num = (select max( invoice.num).....
in the record selection...but it does not like my sub select in the where clause...any work around for this?
in other words...my select returns
1002   1
1002  2
1002 3
1001  1
998  1
998  2
but i only want the first 3 records (invNum= 1002, the max invNum for this client)
using CR XI,  thanks for any insight

Post Author: Aron Sereny
CA Forum: Data Connectivity and SQL
i am working with MS sql 2000
my rpt returns
102  1
102  2
101  1
i would like to limit the result set to the 102 id (the largest, most recent ID)
in query analyzer my select works fine with the where clause something like:
where....
and id = (select max (id) from.....)
crystal does not like the sub select in the where clause (select criteria)
thanks for any help

Similar Messages

  • Who to select max total marks of a student from a stu_marks tale;

    how to select max total marks from a student tab
    Posted: Feb 1, 2007 5:25 AM Reply
    SQL> select st_id max(sum(stu_marks))
    2 from stu_marks;
    select st_id max(sum(stu_marks))
    ERROR at line 1:
    ORA-00923: FROM keyword not found where expected
    thanks

    SQL> with t as (SELECT st_id,
      2                    sum(stu_marks) total_marks
      3             FROM stu_marks
      4             GROUP BY st_id)
      5  select t.st_id, t.total_marks
      6  from t
      7  where t.total_marks = (select max(total_marks)
      8                         from t)
      9  /
         ST_ID TOTAL_MARKS
             2         210
    1 row selected.
    SQL>Cheers
    Sarma.

  • List of STD table used for Ebydos Invoice Cockpit

    Hi Masters,
    Could you plese let me know the list of standard tables used for Ebydos Invoice Cockpit.
    Regards,
    Panneer

    When inside SE11 for MONI, lets say, press the where-used list button and select the option for FUNCTION MODULE INTERFACES to see a list of FMs that take a structure of type MONI as input/output parameter. Although this will not give an exhaustive list of FMs, it will assist you to a good extent.
    Additionally, you can try FM APPLICATION_DATA_GET.
    For STXL, take a look at FM READ_TEXT and associated include file LSTXDUXX for more functions in this function group SAPLSTXD.
    Regards
    Message was edited by: Shehryar Khan
    Message was edited by: Shehryar Khan

  • Using MM excise invoice details in SD report

    hi friends,
    i have a requirement that i have to use MM excise invoice details in SD report.
    inwhich both billing document nos are same .
    can any one explains the clear solution for this report.
    thanks in advance.
    Regards,
    karunakar
    Moderator message: please do more research before asking, show what you have done yourself when asking.
    Edited by: Thomas Zloch on Jun 27, 2011 2:55 PM

    Hi
    you want to see the invoice column in FBL5N report.  first you need to check the current layout selection.  this fields are available or not.  if available then add that fields.
    if fields are not available then goto menu "Settings - special fields" OBVU.
    then add this fields in this.
    before add this fields here.  please check the data is updating in BSEG tables and which fields it has updating.
    hope this will help you.
    Regards
    Ram

  • Select MAX(BUDAT) from ztab (custom table) where... NOT work!

    We use the following statement where BUDAT is one of the fields in our custom table ztab:
    Select MAX(BUDAT) from ztab (custom table) where...
    When activating the above code, get the following error:
    "Unknown column name "MAX(BUDAT)". not determined until runtime, you cannot specify a field list."
    How to resolve this problem to get a max value of the field BUDAT in custom table ztab (it's not an internal table)?
    <REMOVED BY MODERATOR>
    Edited by: Alvaro Tejada Galindo on Apr 10, 2008 3:56 PM

    HI,
    Tyr having a space after and before BUDAT.
    ( BUDAT ).
    Hope it helps,
    Shreekant

  • Using SELECT MAX(Substr( in a subquery to return specific rows

    Oracle v10
    Here's an example of a query and the output
    SELECT ID, SAMPLEID, COMPOUNDNAME, REQUISITION, SUBSTR(REQUISITION,2,4) FROM SEARCH PL1 WHERE SAMPLEID = 'IA 0005 0166';
    86907     IA 0005 0166     IA 0005     R2004:001160     2004
    98158     IA 0005 0166     IA 0005     R2005:000956     2005I am attempting to only return the newest row of data, in this case the 2005 row.
    I tried
    SELECT ID, SAMPLEID, COMPOUNDNAME, REQUISITION, SUBSTR(REQUISITION,2,4) FROM SEARCH PL1
    WHERE SAMPLEID = 'IA 0005 0166' AND
    REQUISITION IN
    (SELECT MAX(SUBSTR(REQUISITION,2,4)) FROM SEARCH PL2
    WHERE SUBSTR(PL2.REQUISITION,2,4) = SUBSTR(PL1.REQUISITION,2,4));But it returns no results. I feel I am missing something simple.
    TIA

    Hi,
    You're comparing a string to a 4-byte substring from the middle of itself. Those two will never be the same.
    Also, I don't think you want the sub-query to be corellated.
    Try this:
    SELECT      id
    ,     sampleid
    ,     compoundname
    ,     requisition
    ,     SUBSTR (requisition, 2, 4)
    FROM     search      pl1
    WHERE     sampleid = 'IA 0005 0166'
    AND     SUBSTR (requisition, 2, 4)     -- Changed
         IN  (
                 SELECT  MAX (SUBSTR (requisition, 2, 4))
              FROM     search pl2
    --           WHERE      SUBSTR (pl2.requisition, 2, 4) = SUBSTR (pl1.requisition, 2, 4)     -- Lose this, maybe
    ;If different substrings of requisition mean different things, then perhaps they should be stored in different columns. It will be easier to combine the different columns when you want to (e.g., for display) than it will be to split the single string apart every time you need to use only part of it, and it will be much more efficient as well.
    If you need to combine them often, you could create a view, or, starting in Oracle 11, use a virtual column.
    I hope this answers your question.
    If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only), and also post the results you want from that data.
    Explain, using specific examples, how you get those results from that data.
    Edited by: Frank Kulash on Dec 20, 2010 12:59 PM
    Formatted code

  • Use of LIKE in where clause of select statement for multiple records

    Hi Experts,
    I have a account number field which is uploaded from a file. Now this account numbers uploaded does not match fully with sap table account numbers but it contains all of the numbers provided in the file mostly in the upright positions.
    For example in file we have account number as 2ARS1 while in sap table the value is 002ARS1.
    And i want to fetch data from sap table based on account number uploaded. So, i am trying to use LIKE with for all entries but its not working as mentioned below but LIKE is not working with FOR ALL ENTRIES.
    data : begin of t_dda occurs 0,
            dda(19) type c,
           end of t_dda.
    data : begin of t_bukrs occurs 0,
            bukrs type t012k-bukrs,
           end of t_bukrs.
    data : dda type t012k-bankn,
           w_dda type t012k-bankn.
    CONCATENATE '%'
                             '2ARS1'
                     INTO  W_DDA.
    MOVE W_DDA TO T_DDA-DDA.
    APPEND T_DDA.
    CLEAR T_DDA.
    free t_bukrs.
    SELECT BUKRS
      FROM T012K
      into TABLE t_bukrs
        for all entries in t_dda
    WHERE BANKN like t_dda-dda.
    Can anybody suggest what should i use to get the data for multiple account numbers using one select statement only instead on using SELECT UP TO 1 ROWS in LOOP....ENDLOOP ?
    Thanks in advance,
    Akash

    Hi,
    yes, For All entries won't work for LIKE with '%  '.
    I think the other alternative is go for Native SQL by writing sub-query
    sample code is here:
    data: begin of i_mara occurs 0,
              matnr like mara-matnr,
              matkl like mara-matkl,
           end of i_mara.
    exec sql.
    select matnr, matkl from mara where matnr in (select matnr from marc) and matnr like '%ma' into :i_mara
    endexec.
    loop at i_mara.
    write:/ i_mara-matnr, i_mara-matkl.
    endloop.
    hope u got it.
    regards
    Mahesh
    Edited by: Mahesh Reddy on Jan 21, 2009 2:32 PM

  • When reporting "Spend" do you use PO Value, Invoice Amount or Goods Receipt

    When reporting "Spend" do you use PO Value, Invoice Amount or Goods Receipt? I am trying to standardize reporting and would like feedback on what is the norm. The users cannot agree so I need to know what the standard is.

    PO Value is what is budgeted for ,
    Invoice is what is actually being paid for.
    GR would give you the value of goods received. My take on this is that it should be Invoice value since this is what is reflected in the books and is actually being paid for...

  • How can I use a where in Select clause?

    How can I use a where in select clasue when the other part of the where I do not not.
    I mean that
    Select *
    from mara
    where MATNR = MT*
    That means it can have MTA, MTB, MTC....and so on
    I can I write this code.
    Regards,
    Subhasish

    hiii
    you can use following query
    SELECT * FORM mara WHERE matnr CONTAINING 'MT'
    or use following
    select * from mara WHERE matnr =  'MT%'
    reward if useful
    thx
    twinkal

  • How to use select max and min query..

    hi gurus,
    we have got a custom report for develoment.
    the report has to fetch the max and min salarys department wise....
    how to pick up max & min sal ansal from table pa0008.

    Hi,
    Try the following
    select max(sal)
               min(sal)
               from <database table>
               into <internal table>
               group by department
               where <where condition>.
    Here we assume that sal is the field holding the salary and department is the name of the field in the database table. Where condition is optional.
    Hope this helps.
    Regards,
    Sachin

  • Make use of the  invoice form available in the correspondence.

    Dear all,
    I want to make use of the invoice smart forms available under the IMG in Corresspondence -->forms -->RE_CN_120. but i am not able to under how to assign this. scine i want to crete invoice for rent . please note that i am working on 4.7.Experst please suggest .
    Regards.
    Varaprasad

    Hi Varaprasad,
    creation of invoice is not available in R/3 4.7 set 2.0. This functionality had been introduced with ERP.
    Please refer to this thread.
    [Create Invoice for rent in 4.7;
    Regards, Franz

  • Any Idea Which Message type/Idoc Type should be used for FI Invoice

    Hi Experts,
    Any idea what message type/Idoc type should be used for FI invoice. We are going to send IDOC from R/3 to Non-SAP System using ALE. We are using T-codes FV60/FV65.
    Thanks,
    Sony

    Hi Sony,
    I never dealt with FI IDoc.
    I think you need to setup EDI outgoing payment in IMG. Please take look this report <b>RFFOALE1</b> - ALE Distribution of Payment Data and <b>RFFOEDI1</b> and check also the program documentation.
    Hope this will help.
    Regards,
    Ferry Lianto

  • I can't download apps. I'm trying to use my debit/visa and it says there is a problem try again, I've tried and tried and I get nowhere my debit/visa has worked before and now I don't even see where I can select "none" as a payment option, anyone kno

    I can't download apps. I'm trying to use my debit/visa and it says there is a problem try again, I've tried and tried and I get nowhere my debit/visa has worked before and now I don't even see where I can select "none" as a payment option, anyone know what to do?

    iTunes Store: Accepted forms of payment
    Apple accepts different payment methods in different countries.
    follow the steps listed in the link to see, it may not let you use a debit card.

  • Using SELECT MAX to default to certain days

    Gurus,
    Right now, I use SELECT MAX("File Date"."Date")FROM "Subject Area" to pull the most recent date available. I'd like for this to pull the last two or three days of data available. Any suggestions?
    I have this set under a report filter for the analysis. Thanks in advance!

    Try this
    SELECT File Date.Date saw_0, TOPN(File Date.Date, 3) saw_1, Facts."#Sales" saw_2 FROM "Subject Area" ORDER BY saw_0
    Let me know updates
    Edited by: Srini VEERAVALLI on May 6, 2013 5:10 PM
    Your initial post talks about logical query from OBIEE, so I've logical query. try to put that in answers instead of running in Toad or sql developer etc..
    Edited by: Srini VEERAVALLI on May 6, 2013 8:20 PM

  • How do you use 3 Where Clauses in a query

    Hi, i am trying to figure out how to use 3 Where Clauses in a Query where 2 of the Where Clauses uses a Sub query.
    Display the OrderID of all orders that where placed after all orders placed by “Bottom-Dollar Markets”.
    Order the result by OrderID in ascending order.
    First WHERE clause checks for OrderDate and uses a sub query with ALL keyword.
    Second WHERE clause use equals and sub query.
    Third WHERE clause uses equal and company name.
    This is what i have so far but i am pretty confused on how to do this.
    My Code for NorthWind:
    Select OrderID
    From Orders o
    Where o.OrderID IN (Select OrderDate From Orders Where Orders.OrderID > ALL
    (Select CompanyName From Customers Where CompanyName = 'Bottom-Dollar Markets'));
    The book shows how to use the ALL Keyword but not in a Sub query with Multiple Where Clauses.
    Select VenderName, InvoiceNumber, InvoiceTotal
    FROM Invoices JOIN Vendors ON Invoices.VendorID = Vendors.VendorID
    WHERE InvoiceTotal > ALL (Select InvoiceTotal From Invoices Where VendorID = 34)
    ORDER BY VendorName;

    >Where Orders.OrderDate
    > ALL  (Select
    CompanyName
    The comparison operator (>) requires compatible data types.
    DATETIME is not compatible with VARCHAR string for comparison.
    Here is your homework:
    SELECT orderid
    FROM orders o
    WHERE o.orderdate > ALL (SELECT orderdate
    FROM orders
    WHERE shipvia = (SELECT Max(shipvia)
    FROM orders o
    INNER JOIN customers c
    ON c.customerid =
    o.customerid
    WHERE
    c.companyname = 'Bottom-Dollar Markets'));
    11064
    11065
    11066
    11067
    11068
    11069
    11070
    11071
    11072
    11073
    11074
    11075
    11076
    11077
    Kalman Toth Database & OLAP Architect
    SQL Server 2014 Database Design
    New Book / Kindle: Beginner Database Design & SQL Programming Using Microsoft SQL Server 2014

Maybe you are looking for

  • ITunes match very spotty

    iTunes match works off and on, more not than so. All software up to date

  • Do Blueray burners work with a PPC G5 (dual 1.8GHz)

    Do Blueray burners work with a PPC G5 (dual 1.8GHz)?

  • XSU for C++

    Does anyone know if there will be a version of XSU for C++? I want to insert/delete/update records in a database, given a XML document from a C++ program. Do I have any other options if I cannot use the current version of XSU? Thanks, Jon Shuler

  • Setting ProGuard options in build.xml (SOLVED)

    Hi guys, I'm trying to obfuscate my MIDlet so I can use BCrypt and the bouncy castle library. I'm getting the following error and I see that I need to add '-dontskipnonpubliclibraryclasses' and/or '-dontskipnonpubliclibraryclassmembers'. I've read Pr

  • No Plain Paper print option when printing on small size papers

    Hi, I am using an Officejet 100 and an Officejet 6500 on a MacBook Pro, Mac OS X 10.5.8. HP Printer Driver version is 12.4. I need to print on plain paper using paper sizes A6 or 4"x6". The print window of the driver does not give a plain paper optio