Get a summary of items by a query with 2 tables (INV1 and RIN1)

Hi!
I have a question about SQL-queries.
When a customer pay an item (sum 100.- Euro), this is written in table INV1.
SELECT T0.DocEntry, T0.ObjType, T0.DocDate, T0.ItemCode, T0.Dscription, T0.LineTotal,T0.SlpCode FROM INV1 T0
show me all entries about all sold items. Thats fine!
When the same customer give back some of this sold item (sum 50.- Euro), this is written in RIN1.
SELECT T0.DocEntry, T0.ObjType, T0.DocDate, T0.ItemCode, T0.Dscription, T0.LineTotal,T0.SlpCode FROM RIN1 T0
shows me the sum of all items that get back.
For a statistc i want evaluate a sum of real sold items (sum of money).
Now, i want create a query that evaluate a sum of the table INV1 and RIN1 and want show the result.
Example for a result:
DocEntry       ObjType       DocDate       ItemCode       Descriton       LineToal
1       13       01.01.06       11111       ItemOne       100.- Euro
2       14       05.01.06       11111       ItemOne       - 50.- Euro
                                          total sum:               50.- Euro
is there a way that show me this result (query, form, etc.)?
How can i realize it?
Thanks a lot!
Juergen

I'm a SQLServer newbie from the Oracle world, so there may be a simpler way to do this, but the following will return all the data that you need, although it may not be pretty:
SELECT 'Detail' LineType, T0.DocEntry, T0.ObjType, T0.DocDate, T0.ItemCode, T0.Dscription, T0.LineTotal,T0.SlpCode FROM INV1 T0
union all
SELECT 'Detail' LineType, T0.DocEntry, T0.ObjType, T0.DocDate, T0.ItemCode, T0.Dscription, T0.LineTotal,T0.SlpCode FROM RIN1 T0
union all
select 'Total' LineType, null DocEntry, null ObjType, null DocDate, null ItemCode, null Dscription, sum(LineTotal) LineTotal, null SlpCode from
(SELECT T0.DocEntry, T0.ObjType, T0.DocDate, T0.ItemCode, T0.Dscription, T0.LineTotal,T0.SlpCode FROM INV1 T0
union all
SELECT T0.DocEntry, T0.ObjType, T0.DocDate, T0.ItemCode, T0.Dscription, T0.LineTotal,T0.SlpCode FROM RIN1 T0 ) x
order by 1,2

Similar Messages

  • Af:query with bind variables and Saved Search

    I have a VO and view criteria(VC).
    VC has a criteria item ObsoleteDate with range specified as bindVariables "dateFrm" and "dateTo" I dragged & dropped the named criteria as af:Query with table. Table toolbar has 2 buttons in which I set & clear the bind variables. Data is fetched as per as expected based on the VC & bind variables.
    The problem is,
    If I save my search with bind variables set and swap between the saved searches , all works fine. But the moment I clear bind variables & swap between searches.. "dateFrm" is populated and "dateTo" is null and I get an Exception oracle.jbo.AttrValException: JBO-27035: Attribute Obsolete Date: is required.
    Why is this happening?? Saved search is supposed to save the VC with all the bind values set while saving and clearing bind variables shouldn't affect the saved search, right?? Or I have understood it wrong?
    I am using JDeveloper 11.1.2.3.0
    Thanks

    Try
    like ? || '%'

  • Query with MARA MVKE and MAST

    Hi
      Im trying to create a query with MARA, MVKE and MAST tables. If corresponding records exist in all the 3 tables, I get output. Otherwise, I get the result as 'No data selected'. I tried using left outer join with MAST , tried using MARC also between MARA and MAST but its of no use. Please suggest how I can both get the sales data and BOM details in the output.
    Thanks
    Aparna

    Hi Aparna,
    Goto  SE16 Check in table,
    1.KDST -
    Sales order to BOM link
    2.STKO -
    BOM - header
    3.STPO -
    BOM - item
    And also you create a query and check the out put.

  • How do I create a folder or report from a query with a union and parameters

    I have created folders with unions but I am having difficulty coverting a query with a union and parameters.
    The following works great in SQL*Developer without parameters, but I want to change to use parameters for the year and quarter and use it in Discoverer:
    SELECT TO_CHAR(NVL(AV.TAX_ID,999999999),'000000000') FEID,
      AV.FIRM_NAME VENDOR_NAME,
      AV.BIDCLASS CONTRACT_CODES,
      AV.AWAMT AWARD_AMOUNT,
      AV.SOL_MODE FORMAL_INFORMAL,
      AV.CERT BUSINESS_ENTITY,
      AV.ETHNICITY ETHNICTY,
      AV.PO_NUMBER_FORMAT CONTRACT,
      SUM(VP.INVOICE_AMOUNT) AMOUNT_PAID_$
    FROM CONFIRM.VSTATE_PAID_AWARD_VENDORS AV,
      CONFIRM.VSTATE_VENDOR_PAYMENTS VP
    WHERE ( ( AV.PO_NUMBER = VP.PO_NUMBER
    AND AV.VENDOR_ID       = VP.VENDOR_ID ) )
    AND (TO_CHAR(VP.PAYMENT_DATE,'Q') = '4')
    AND ( TO_CHAR(VP.PAYMENT_DATE,'YYYY') = '2009' )
    GROUP BY TO_CHAR(NVL(AV.TAX_ID,999999999),'000000000'),
      AV.FIRM_NAME,
      AV.BIDCLASS,
      AV.AWAMT,
      AV.SOL_MODE,
      AV.CERT,
      AV.ETHNICITY,
      AV.PO_NUMBER_FORMAT
      union
    SELECT TO_CHAR(NVL(AV2.TAX_ID,999999999),'000000000') FEID,
      AV2.FIRM_NAME VENDOR_NAME,
      AV2.BIDCLASS CONTRACT_CODES,
      AV2.AWAMT AWARD_AMOUNT,
      AV2.SOL_MODE FORMAL_INFORMAL,
      AV2.CERT BUSINESS_ENTITY,
      AV2.ETHNICITY ETHNICTY,
      AV2.PO_NUMBER_FORMAT CONTRACT,
      0 AMOUNT_PAID_$
    FROM CONFIRM.VSTATE_PAID_AWARD_VENDORS AV2
    WHERE
    not exists (SELECT 'X'
                  FROM CONFIRM.VSTATE_VENDOR_PAYMENTS VP2
                 WHERE av2.po_number = vp2.po_number
                       AND (TO_CHAR(VP2.PAYMENT_DATE,'Q') = '4')
                       AND ( TO_CHAR(VP2.PAYMENT_DATE,'YYYY') = '2009' ))
    AND (TO_CHAR(AV2.AWDATE,'Q') = '4')
    AND (to_CHAR(AV2.AWDATE,'YYYY') = '2009')
    GROUP BY TO_CHAR(NVL(AV2.TAX_ID,999999999),'000000000'),
      AV2.FIRM_NAME,
      AV2.BIDCLASS,
      AV2.AWAMT,
      AV2.SOL_MODE,
      AV2.CERT,
      AV2.ETHNICITY,
      AV2.PO_NUMBER_FORMAT Can someone provide a solution?
    Thank you,
    Robert

    Hi,
    You can take the parameters to the select so that you will be able to create conditions over them.
    Try to use this SQL instead of your and in the discoverer workbook create the conditions and parameters:
    SELECT TO_CHAR(NVL(AV.TAX_ID,999999999),'000000000') FEID,
    AV.FIRM_NAME VENDOR_NAME,
    AV.BIDCLASS CONTRACT_CODES,
    AV.AWAMT AWARD_AMOUNT,
    AV.SOL_MODE FORMAL_INFORMAL,
    AV.CERT BUSINESS_ENTITY,
    AV.ETHNICITY ETHNICTY,
    AV.PO_NUMBER_FORMAT CONTRACT,
    TO_CHAR(VP.PAYMENT_DATE,'YYYY') P_YEAR,
    TO_CHAR(VP.PAYMENT_DATE,'Q') P_QTR
    SUM(VP.INVOICE_AMOUNT) AMOUNT_PAID_$
    FROM CONFIRM.VSTATE_PAID_AWARD_VENDORS AV,
    CONFIRM.VSTATE_VENDOR_PAYMENTS VP
    WHERE ( ( AV.PO_NUMBER = VP.PO_NUMBER
    AND AV.VENDOR_ID = VP.VENDOR_ID ) )
    --AND (TO_CHAR(VP.PAYMENT_DATE,'Q') = '4')*
    --AND ( TO_CHAR(VP.PAYMENT_DATE,'YYYY') = '2009' )*
    GROUP BY TO_CHAR(NVL(AV.TAX_ID,999999999),'000000000'),
    AV.FIRM_NAME,
    AV.BIDCLASS,
    AV.AWAMT,
    AV.SOL_MODE,
    AV.CERT,
    AV.ETHNICITY,
    AV.PO_NUMBER_FORMAT ,
    TO_CHAR(VP.PAYMENT_DATE,'YYYY') P_YEAR,
    TO_CHAR(VP.PAYMENT_DATE,'Q') P_QTR
    union
    SELECT TO_CHAR(NVL(AV2.TAX_ID,999999999),'000000000') FEID,
    AV2.FIRM_NAME VENDOR_NAME,
    AV2.BIDCLASS CONTRACT_CODES,
    AV2.AWAMT AWARD_AMOUNT,
    AV2.SOL_MODE FORMAL_INFORMAL,
    AV2.CERT BUSINESS_ENTITY,
    AV2.ETHNICITY ETHNICTY,
    AV2.PO_NUMBER_FORMAT CONTRACT,
    TO_CHAR(VP.PAYMENT_DATE,'YYYY') P_YEAR,
    TO_CHAR(VP.PAYMENT_DATE,'Q') P_QTR
    0 AMOUNT_PAID_$
    FROM CONFIRM.VSTATE_PAID_AWARD_VENDORS AV2
    WHERE
    not exists (SELECT 'X'
    FROM CONFIRM.VSTATE_VENDOR_PAYMENTS VP2
    WHERE av2.po_number = vp2.po_number
    AND (TO_CHAR(VP2.PAYMENT_DATE,'Q') = TO_CHAR(VP.PAYMENT_DATE,'Q') )
    AND ( TO_CHAR(VP2.PAYMENT_DATE,'YYYY') = TO_CHAR(VP.PAYMENT_DATE,'YYYY') ))
    --AND (TO_CHAR(AV2.AWDATE,'Q') = '4')*
    --AND (to_CHAR(AV2.AWDATE,'YYYY') = '2009')*
    GROUP BY TO_CHAR(NVL(AV2.TAX_ID,999999999),'000000000'),
    AV2.FIRM_NAME,
    AV2.BIDCLASS,
    AV2.AWAMT,
    AV2.SOL_MODE,
    AV2.CERT,
    AV2.ETHNICITY,
    AV2.PO_NUMBER_FORMAT,
    TO_CHAR(VP.PAYMENT_DATE,'YYYY') P_YEAR,
    TO_CHAR(VP.PAYMENT_DATE,'Q') P_QTR
    Tamir

  • How can I create a query with tables in INFOSET?

    Dear Gurus,
    How can I create a query with tables in INFOSET?
    Just tables and fields INFOSET?
    Kind Regards,

    Hello
    Check following SCN Article for your understanding/reference:
    - [Using Infoset Query ,SAP Query and Quick Viewer|http://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/10eab7af-0e54-2c10-28a5-87b47adbe1a5]
    Regards
    JP

  • When i try to update my itunes on my pc i keep getting the messaage that there was a problem with the installer and it could not finish. how do i fix this? i`ve tried to download 3 times already.

    when i try to update my itunes on my pc i keep getting the messaage that there was a problem with the installer and it could not finish. how do i fix this? i`ve tried to download 3 times already.

    Hi
    I've got a similar problem.  iTunes v10.2 worked fine, but when I tried to update it to 10.5 I got a 'Bonjour' error.  I eventually solved that but I still couldn't upgrade to 10.5, so I deleted every single Apple, Quicktime, iTunes, etc file on my PC using Revo Unistaller (because the normal Windows Add/Delete programs wouldn't work) but now, when I install the latest iTunes version from scratch (on XP SP3), it says: "the installer encountered errors before it could be configured.... your system has not been modified" 
    Any ideas?
    Rick

  • My iPad 4 wifi 3G keeps charging slowly takes half a hour to get to 15% when plug into the wall with the plug and the lead what come with the iPad just wondering as I think some thing is wrong with the iPad

    My iPad 4 wifi 3G keeps charging slowly takes half a hour to get to 15% when plug into the wall with the plug and the lead what come with the iPad just wondering as I think some thing is wrong with the iPad

    Using the battery level meter in this manner is comparable to using your car's fuel gauge to calculate miles per gallon. The only thing that matters is the total amount of operating time from full charge to auto-shutdown.
    Use the wall-mount charger that came with the iPad and charge overnight.  Do NOT use an iPod/iPhone charger.  Do NOT use a computer's USB port.  Then, operate it normally until auto shut-down (ignore any low level alerts that may appear).  An irony is that doing that test to determine the total operating time is also the procedure necessary to calibrate the battery level meter.
    I'm not claiming that you do not have a problem.  I am stating, however, that we don't yet know.  If the above test does, in fact, indicate a problem, read this.
    Also, according to Apple:
    Use Your iPad Regularly
    For proper reporting of the battery’s state of charge, be sure to go through at least one charge cycle per month (charging the battery to 100% and then completely running it down).
    Elsewhere, Apple elaborates and explains that two half-discharges (or four quarter-discharges, etc.) equals one full discharge.

  • Absolute dynamic select query with dynamic join and where

    Has anyone ever tried creating an absolutely dynamic SELECT query with dynamic Join and Where conditions.
    I have a requirement of creating such a query in an Utility Class, and i have written the code. But its throwing my sysntax errors.
    Please let me know where am I going wrong OR is it really possible to create such a dynamic Query??
        SELECT (FIELDS) INTO TABLE IT_TABLES
          FROM ( (ME->TABLE1)  inner join ( me->table2 )
          on ( on_condition ) )
          WHERE (me->where_fields).
    Ags.

    It worked for me in a following way:
    select * into corresponding fields of table <result_table>
            from (join_string)
            where (l_where).
    Where the contents of join_string were dynamically build using concatenation. So it will be something like
    concatenate ME->TABLE1 'as a INNER JOIN' me->table2 'as b ON (' into join_string separated by space.
    <...>
    add here matching/reference colums, something like
    concatenate 'a~' me->TABLE1_JOIN_COL into temp1.
    concatenate 'b~' me->TABLE2_JOIN_COL into temp2.
    concatenate join_string temp1 '=' temp2 into join_string separated by space.
    <...>
    concatenate join_string ')' into join_string separated by space.
    And then use similar approach for l_where variable.

  • Sync .mov and .mp4 gets an error saying it is not compatible with iPad 2 and will not copy. Help.

    Trying to sync .mov and .mp4 and get an error saying it is not compatible with iPad 2 and will not copy. Itunes will not even copy the files to give me a chance to work with them on the iPad.

    highlight the file and go to iTune menu ADVANCED and select create iPad or AppleTV version.

  • Rewrite the query with out joins and group by

    Hi,
    This was an interview question.
    Table Names: bookshelf_checkout
    bookshelf
    And the join condition between these two tables is title
    We need to rewrite below query without using join condition and group by clause ?
    SELECT b.title,max(bc.returned_date - bc.checkout_date) "Most Days Out"
               FROM bookshelf_checkout bc,bookshelf b
               WHERE bc.title(+)=b.title
               GROUP BY b.title;When I was in college, I read that most of the SELECT statements can be replaced by basic SQL operations (SET OPERATORS). Now I am trying to rewrite the query with SET operators but not able to get the exact result.
    Kindly help me on this.
    Thanks,
    Suri

    Something like this?
      1  WITH books AS (
      2  SELECT 'title 1' title FROM dual UNION ALL
      3  SELECT 'title 2' FROM dual UNION ALL
      4  SELECT 'title 3' FROM dual ),
      5  bookshelf AS (
      6  SELECT 'title 1' title, DATE '2012-05-01' checkout_date, DATE '2012-05-15' returned_date FROM dual UNION ALL
      7  SELECT 'title 1' title, DATE '2012-05-16' checkout_date, DATE '2012-05-20' returned_date FROM dual UNION ALL
      8  SELECT 'title 2' title, DATE '2012-04-01' checkout_date, DATE '2012-05-15' returned_date FROM dual )
      9  SELECT bs.title, MAX(bs.returned_date - bs.checkout_date) OVER (PARTITION BY title) FROM bookshelf bs
    10  UNION
    11  (SELECT b.title, NULL FROM books b
    12  MINUS
    13* SELECT bs.title, NULL FROM bookshelf bs)
    SQL> /
    TITLE   MAX(BS.RETURNED_DATE-BS.CHECKOUT_DATE)OVER(PARTITIONBYTITLE)
    title 1                                                           14
    title 2                                                           44
    title 3Lukasz

  • Query with drill down and w/o drill down

    Hi experts,
    We created a query with a RKF. In the output we are getting the RKF value correctly. But when we dril
    downed a characteristic i.e Special GL Ind the output is not matching. It is showing incorrect value when
    compared with the value without drill down. But if we remove the drill down then it is showing the correct
    value. What is the reason for this ?
    Regards,
    smitha.

    Our RKF def is as follows:
    Keyfigure: 0deb_cre_lc
    Chars:
    Posting Keys: 01,02,11,12
    Year start date: Restricting it with a variable created on it. Variable is of type Customer exit.This variable
    gets value from key date which is entered by user dynamically.
    Specified the offsets of Yr start date as 0 to 365.
    Regards,
    smitha.

  • ABAP Query: FI Tables - BSEG and BKPF

    Dear All,
    I have tried to use SAPQuery - SQ01 to join 2 SAP tables (BSEG and BKPF) by creating an Infoset (SQ01 >> Environment >> Infosets >> Create)
    However, there is always an error message for the table join when I generate the infoset. Tables BSEG and BKPF are joined together by conditions BSEG-BELNR & BKPF-BELNR; BKPF-BURKS & BKPF-BURKS; BSEG-GJAHR and BKPF-GJHAR.
    The error message prompted is, "You cannot use comparisons with column references in pool and cluster". Is the message trying to say that BELNR, NURKS and GJAHR are column references in pool and cluster, thats why we can't join the tables?
    The purpose of the infoset is to extract accounting documents. I will need to extract accounting doc data from DEV, QA and Prodcution Server.  If I use SAP QuickViewer, everytime I go to a differenct server I will need to create the QuickViewer in the system before I can use it. But if i use SAP Query, i will need to create once and transport the SAP Query to another server.
    Kindly advise if there is a way I can extract accountng document by using SAP Query?
    Million Thanks in Advance.

    Hi Mark,
    I appreciate your response.
    Im tyring to extract information for open GL items. Thus the relevant tables would be BSIS. But I find that  some fields such as Purchase Order Number; Purchase Order Line Item, Asset No.,Asset Sub-No which Im interested in do not exist in BSIS. But these fields can be found in Table BSEG?
    If I have to link BSEG and BKPF, how should i go about doing it?
    Kindly advise.
    Thanks in Advance!

  • Query with tables VEPVG, VBAK, VBAP AND KONV

    hi all,
    I have a requirement, that is Open Sale Orders which is having Special Discount. I am trying to write a Query, But KONV table is not coming into the joins. my execution plans is bellow
    VEPVG  -->  VBAK         vbak-knumv = konv-knumv and konv-kschl = Special Discount
                        VBAP
    Please explain me, how to design the query with conditions.
    Thanks & Regards,
    Srinivas

    Hi,
    Have you referred this help document.
    http://help.sap.com/printdocu/core/Print46c/EN/data/pdf/BCSRVQUE/BCSRVQUE.pdf
    Regards - Shree

  • I use the same e-mail account on my PC and ipad.  Lately I have been getting an e-mail that says no sender with no content and a date of 1969.  It shuts down some of my e-mails and goes away later.  this does not occur on my PC

    I keep getting on my e-mail a no sender with a date of 1969, wipes out my e-mails temporarily but doesn't happen on my PC?

    Try turning the account off and on : Settings > Mail, Contacts, Calendars , then tap the account on the right, slide Mail to 'off', exit settings and go back into the Mail app, and then go back to Settings and slide Mail back to 'on'
    If that doesn't work then try closing the Mail app via the iPad’s multitasking bar (I'm assuming that your iPad is on iOS 7) : double-click the home button to open the taskbar and then swipe or drag the Mail app's 'screen' up and off the top of the screen to close it, and click the home button to close the taskbar.
    And do a soft-reset : press and hold both the sleep and home buttons for about 10 to 15 seconds (ignore the red slider), after which the Apple logo should appear - you won't lose any content, it's the iPad equivalent of a reboot.

  • Query from table a and insert to table b

    Hi,
    I would like to create an attendance page to record student's attendance on a particular dates.
    I have 2 tables - students and attendance tables; in which attendance table will consist of PK from students table and date.
    How do I create a form that display all the students record in a page with checkbox and date column; and when user check the boxes and click save; it will insert record into attendance table? Thanks!
    Layout similar to the below:
    Date: 1/1/2010 (user input)
    Name: Attend
    student 1 (checkbox)
    student 2 (checkbox)
    student 3 (checkbox)
    student 4 (checkbox)
    .....

    Hi Aaron,
    For this you can do the following
    1. Create a Tabular Form on The STUDENT table, i.e. the table you are using as a Fecth only table
    2. Make the ApplyMRU and ApplyDRD process conditions Never so they will not be executed
    3. Write your own custom process to write the checked rows into Attendence Table.
    In the process you will have to refer to the checkbox f+nn+ item using APEX_APPLICATION.G_F+nn+ array and write from similar arrays for the other tabular form items
    You will find useful code snippets in the Apex Help , Advanc3ed Tutorials as well as here http://www.oracle.com/technology/products/database/application_express/howtos/tabular_form.html#MANUAL
    Regards,

Maybe you are looking for

  • Nokia 620 melting usb port

    18 month old phone. Plugged in to top up the charge. Usual charger, usual cable. 20 minutes later smoke and meltdown. USB port dripping melted plastic. Burnt finger. A quick goggle and a search on here. I am not alone it seems. Does anyone have a tec

  • Please advise which iPod I should buy

    I'm a newbie when it comes to iPods. I currently have a 2GB nano that I take with me when running but I intend to buy a video iPod big enough to store all my CD's on it. I will not be using it to watch videos, I just need the big storage capacity. I

  • Data Rescue II AND Disksaver for failing hard drive?

    I need some guidance on rescuing data from an internal hard drive that Disk Utility could not fix. (The drive is making an odd noise, and apparently has a mechanical problem.) Data Rescue II appears to successfully cloned my iMac's drive, while Carbo

  • Upgrading from SSM-10 to ASA 5525x

    We are upgrading from an ASA 5510 with a SSM-10 module to the 5525x ips.  Can we simply copy the config from the SSM-10 to the 5525x?

  • Unable to download Mavericks from AppStore - Error 1004

    I want to redownload Maverick to diagnose and possibly fix a problem with iTunes. After which I may upgrade to Yosemite I go into Appstore, click on 'Purchases' then try to download Mavericks.  The action fails with the error message "Error 1004 plea