How to implement left join for the below sql.

i need to perform left join between inventory table and purchase table and inventory table with sales table.
please let me know the syntax.
SELECT Tbl_ProductGroupMaster.ProdName, Tbl_ProductGroupMaster.UnitNam, Tbl_Inventory.CrDate, Tbl_Inventory.QtyOpStk, Tbl_Inventory.QtyClStk, Tbl_Inventory.ExcShortage, purchase.SumOfNUnit, sales.SumOfQty
FROM Tbl_ProductGroupMaster, Tbl_Inventory left join
[SELECT Tbl_PurchaseMain.idate as p_idate, Tbl_PurchaseSub.Proid as proid,
sum(Tbl_PurchaseSub.NUnit) AS SumOfNUnit
FROM Tbl_PurchaseMain, Tbl_PurchaseSub WHERE Tbl_PurchaseMain.GID=Tbl_PurchaseSub.gid
and format(cdate(Tbl_PurchaseMain.idate),'mm-dd-yyyy') between format(cdate('13-Sep-2009'),'mm-dd-yyyy') and
format(cdate('02-Oct-2009'),'mm-dd-yyyy') GROUP BY
Tbl_PurchaseMain.idate, Tbl_PurchaseSub.Proid]. AS purchase on (Tbl_Inventory.CrDate = purchase.p_idate)
left join
[SELECT Tbl_SalesMain.idate AS s_idate, Tbl_SalesSub.Proid, sum(Tbl_SalesSub.Qty) AS SumOfQty
FROM Tbl_SalesMain, Tbl_SalesSub
WHERE Tbl_SalesMain.SAID=Tbl_SalesSub.SAID And
format(cdate(Tbl_SalesMain.idate),'mm-dd-yyyy') Between format(cdate('13-Sep-2009'),'mm-dd-yyyy') And
format(cdate('02-Oct-2009'),'mm-dd-yyyy')
GROUP BY Tbl_SalesMain.idate, Tbl_SalesSub.Proid]. AS sales on (Tbl_Inventory.CrDate = sales.s_idate)
WHERE
Tbl_ProductGroupMaster.PROID=Tbl_Inventory.proid AND
Tbl_Inventory.PROID=purchase.proid and
Tbl_Inventory.PROID=sales.proid and
Tbl_Inventory.CrDate = '13-Sep-2009';
thanks,
Vinodh

Completely unstested as you haven't given much information but do you mean something like this?
WITH purchase
       AS (  SELECT   Tbl_PurchaseMain.idate AS p_idate,
                      Tbl_PurchaseSub.Proid AS proid,
                      SUM (Tbl_PurchaseSub.NUnit) AS SumOfNUnit
               FROM   Tbl_PurchaseMain, Tbl_PurchaseSub
              WHERE   Tbl_PurchaseMain.GID = Tbl_PurchaseSub.gid
                      AND format (cdate (Tbl_PurchaseMain.idate), 'mm-dd-yyyy') BETWEEN format (
                                                                                           cdate('13-Sep-2009'),
                                                                                           'mm-dd-yyyy'
                                                                                    AND  format (
                                                                                            cdate('02-Oct-2009'),
                                                                                            'mm-dd-yyyy'
           GROUP BY   Tbl_PurchaseMain.idate, Tbl_PurchaseSub.Proid),
    sales
       AS (  SELECT   Tbl_SalesMain.idate AS s_idate,
                      Tbl_SalesSub.Proid,
                      SUM (Tbl_SalesSub.Qty) AS SumOfQty
               FROM   Tbl_SalesMain, Tbl_SalesSub
              WHERE   Tbl_SalesMain.SAID = Tbl_SalesSub.SAID
                      AND format (cdate (Tbl_SalesMain.idate), 'mm-dd-yyyy') BETWEEN format (
                                                                                        cdate('13-Sep-2009'),
                                                                                        'mm-dd-yyyy'
                                                                                 AND  format (
                                                                                         cdate('02-Oct-2009'),
                                                                                         'mm-dd-yyyy'
           GROUP BY   Tbl_SalesMain.idate, Tbl_SalesSub.Proid)
SELECT   Tbl_ProductGroupMaster.ProdName,
         Tbl_ProductGroupMaster.UnitNam,
         Tbl_Inventory.CrDate,
         Tbl_Inventory.QtyOpStk,
         Tbl_Inventory.QtyClStk,
         Tbl_Inventory.ExcShortage,
         purchase.SumOfNUnit,
         sales.SumOfQty
FROM   Tbl_ProductGroupMaster,
       Tbl_Inventory LEFT OUTER JOIN purchase
                     ON Tbl_Inventory.CrDate = purchase.p_idate
                     LEFT OUTER JOIN sales
                     ON Tbl_Inventory.CrDate = sales.s_idate
WHERE Tbl_ProductGroupMaster.PROID = Tbl_Inventory.proid
AND   Tbl_Inventory.PROID = purchase.proid
AND   Tbl_Inventory.PROID = sales.proid
AND   Tbl_Inventory.CrDate = '13-Sep-2009';Cheers
Ben
http://www.munkyben.wordpress.com

Similar Messages

  • How to implement  BADI's for the below issue

    Hi All,
    The URL is being populated correctly (without any spaces) to the follow on document (PR/PO) created in R/3 after implementing code corrections in BBP (replacing space by ‘=’ as shown below).
    When sending the PO to supplier portal, the outbound IDOC segment does not get populated properly. The text format ‘=’ is again converted to space in ECC 6.0 which was not the case with 4.5B.
    This is an upgrade issue as the function module used to format text ‘FORMAT_TEXTLINES’ is completely different in ECC 6.0. The entire code of this function module in 4.5B has been commented in ECC 6.0 and new code has been implemented which splits the text and inserts spaces while formatting as shown below.
    This issue can be resolved by implementing a customer exit or a BADI which gets called after standard SAP populates the IDOC. It requires implementing custom code to remove the unwanted spaces inserted by standard SAP for text id F07. Hence after SAP completes its processing to populate the IDOC, the text would be processed further to remove unwanted spaces before actually sending the IDOC out from SAP R/3.
    Thus this upgrade issue resolution requires R/3 development
    1.     BADI Definition:  ME_MMPUR_EINM, Method: PROCESS_TEXT
    This option is preferable.
    2.     User exit: EXIT_SAPLEINM_002
    I need your help on how to write this code in the form of BADI's.where we write and how to implement. ASAP
    thanks,
    Sridhar

    Hi All,
    The URL is being populated correctly (without any spaces) to the follow on document (PR/PO) created in R/3 after implementing code corrections in BBP (replacing space by ‘=’ as shown below).
    When sending the PO to supplier portal, the outbound IDOC segment does not get populated properly. The text format ‘=’ is again converted to space in ECC 6.0 which was not the case with 4.5B.
    This is an upgrade issue as the function module used to format text ‘FORMAT_TEXTLINES’ is completely different in ECC 6.0. The entire code of this function module in 4.5B has been commented in ECC 6.0 and new code has been implemented which splits the text and inserts spaces while formatting as shown below.
    This issue can be resolved by implementing a customer exit or a BADI which gets called after standard SAP populates the IDOC. It requires implementing custom code to remove the unwanted spaces inserted by standard SAP for text id F07. Hence after SAP completes its processing to populate the IDOC, the text would be processed further to remove unwanted spaces before actually sending the IDOC out from SAP R/3.
    Thus this upgrade issue resolution requires R/3 development
    1.     BADI Definition:  ME_MMPUR_EINM, Method: PROCESS_TEXT
    This option is preferable.
    2.     User exit: EXIT_SAPLEINM_002
    I need your help on how to write this code in the form of BADI's.where we write and how to implement. ASAP
    thanks,
    Sridhar

  • How to deal with BRS for the below scenario?

    Hi,
    I would like to know the solution for the below scenario for BRS:
    I have a customer who was maintaining their accounts with Tally software for their previous Financial Year. This year they have shifted to SAP B1 2005B. They have issued few cheques for their vendors in the month of march 2008 which has been realised in the month of April 2008. As per Tally, the closing balance of their bank is 8 Lakh but as per the bank statement, their closing balance is 23 Lakhs. In SAP, the opening Balance for the bank is considered as 23 Lakhs. Now there are 15 Lakh worth cheques which were not realised for the month of March 2008.
    Example:
    abc a/c - 3Lakh
    def a/c - 5lakh
    xyz a/c - 7 lakh
    How do i reconcile for this scenario and what procedures do i follow in SAP?
    Thanks and Regards,
    Kaushal

    Hi Kamlesh,
    Thanks for your response.
    Actually, In the "Process External Bank Statement" window, i see that there are few entries which is for the previous year and which has not been reconciled. I have never worked practically on BRS and hence, i am scared to make any changes in the clients database without being confident on what i am doing. I need to reconcile for one of their Bank a/c for the month of April '08. I have the copy of the statements for the month ending 31st Mar 08 and 30th Apr 08. The closing balances are as below:
    31/03/08 - 2300000.00
    30/04/08 - 3100000.00
    Now my OB for Bank a/c for April '08 in SAP is 2300000.00 Dr.
    When i go to External Bank Reconciliation - Selection Criteria Screen (Manual Reconciliation), here are the detail that i enter:
    Last Balance: INR -7,000,000.00000 (Grayed out by the system)
    Ending Balance: INR -3,100,000.00000 (Entered by me)
    End Date: 30/04/08 (Entered by me)
    "Reconciliation Bank Statement" Screen opens up and shows the below balances in the screen:
    Cleared Book Balance: INR -7,000,000.00000
    Statement Ending Balance: INR -3,100,000.00000
    Difference: INR 3,800,000.00000
    As per the Bank statement, i have found all the transactions listed out here for the month of Apr '08 but, i also found that the open transactions for the previous month from April '08 have been lying in "Process External Bank Statement" window.
    Could you please help me solve my issue as to what needs to be done or could you also get me some links from where i can get few documents for processing External Bank Reconciliations?
    That will be of a great help for me. I need steps as to what needs to be done first and then the next so that i can arrive at the correct closing balance for the month April '08.
    Thanks in Advance....
    Regards,
    Kaushal

  • How to implement tool-tip for the list items for the Choice column in SharePoint 2013

    I had created a simple list with a "Choice" column, i have three entries in my drop-down, 
    First Entry
    Second Entry
    Third Entry.
    If i select any entries in drop-down and hour-over (Second Entry), a
    tool-tip need need to show. 
    Is it possible? If yes how to implement any help will be appreciated.

    Hi,
    We can use JavaScript to achieve it.
    The following code for your reference:
    <script type="text/javascript" src="/sites/DennisSite/Shared%20Documents/js/wz_tooltip.js"></script>
    <script type="text/javascript" src="/sites/DennisSite/Shared%20Documents/js/jquery-1.11.1.min.js"></script>
    <script type="text/javascript">
    $(function () {
    $("select[title='Choice']").change(function(){
    Tip($(this).val());
    $("select[title='Choice']").mouseout(function(){
    UnTip();
    </script>
    Download wz_tooltip.js:
    http://www.walterzorn.de/en/tooltip/tooltip_e.htm#download
    Best Regards
    Dennis Guo
    TechNet Community Support

  • I'm trying to download what's app chatting application and the massage given (need your secret answers for the below questions to proceed your purchase request ) but the problem is I forgot my answers :((( how can I reset the questions and the answer ????

    I'm trying to download what's app chatting application and the massage given (need your secret answers for the below questions to proceed your purchase request ) but the problem is I forgot my answers :((( how can I reset the questions and the answer ????

    Visit this site: http://support.apple.com/kb/HT5312

  • How to use LEFT JOIN in LINQ

    I have this query in Oracle and I am trying to write a Linq query for this below sql. There are 2 datatables DATA_TABLE1 and DATA_TABLE2. Both tables have 2 fields ID1 and ID2.
    SELECT A.ID1, A.ID2
    FROM DATA_TABLE1 A
    LEFT JOIN DATA_TABLE2 B
    ON A.ID1 = B.ID1 AND A.ID2 = B.ID2
    WHERE B.ID1 IS NULL OR B.ID2 IS NULL

    In order to see what query the data provider sent to the server you can do the following.
    Just after creating the data context place this line in the code.
    db.Database.Log = Console.Write;
    Then place a breakpoint after the next line of code, shown next.
    var
    a =
    db.product.Where(p
    =>
    p.Name.Contains(asKeyword)).ToList();
    Then run the application and when it hits the breakpoint open the Visual Studio Output window and the SQL sent to the server should be displayed.
    Fernando (MCSD)
    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".
    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects
    and unknown namespaces.

  • IMPLEMENTING GUI SATUS FOR THE LIST

    HI
    I am a newbie to ABAP and netweaver.
    I am currently studying BC400 and doing exercise 17.
    Unfortunately the whole explanation of how to add or remove functionaly from
    buttons (Save for instance) is very lacking.
    Can someone refer me to a better source/tutorial that explains
    how SET PF-STATUS 'LIST'
    is implemented?
    Thanks
    yuval

    Hi,
    The below one i copied from the web ..
    You set the dialog status for lists in the same way as for normal screens, that is, using the statement
    SET PF-STATUS <stat> [EXCLUDING <f>|<itab>]
                         [OF PROGRAM <prog>]
                         [IMMEDIATELY].
    This statement sets the status <stat> for the current output list. The dialog status <stat> must be defined for the current program, unless you have used the OF PROGRAM addition to set a status from another program <prog>. The status is active for all subsequent list levels until you set another status. The SY-PFKEY system field always contains the status of the current list.
    Using SET PF-STATUS, you can display different user interfaces for different list levels to provide the user with different functions according to the individual requirements. Use SET PF-STATUS SPACE to set the standard list status. This depends on the event blocks in the program, as described above.
    The EXCLUDING option allows you to change the appearance and available functions of a status from within the program. This is useful if the individual user interfaces for a range of list levels are very similar. You can define a single global status, and then just deactivate the functions you do not need using EXCLUDING. Specify <f> to deactivate the function code stored in field <f>. Specify <itab> to deactivate all function codes stored in the internal table <itab>. Field <f> and the lines of table <itab> should be defined with reference to the system field SY-UCOMM.
    The IMMEDIATELY addition is intended specially for list processing. You use it while creating a detail list within an event block to change the status of the list currently displayed (index SY-LISTI). Without this option, the system changes the status of the current secondary list (SY-LSIND) that is displayed only at the end of the processing block.
    Regards
    Sudheer

  • No Implementing class registered for the Interface : ES-TransportationOrderSCMExecutionRequest_In

    Dear PI Experts,
    I'm currently working on an integrated solution between TM <=> PI <=>ECC. When I trigger the Shipment creation from TM to ECC, I received an error in the SXMB_MONI of ECC.
    In the XML, I figured the error that No Implementing class registered for the Interface TransportationOrderSCMExecutionRequest_In .
    May I ask you advices on this issue? Is it a mapping error on ECC or PI Side?
    Thanks in advance for you help and advice.
    Kr,
    JP

    Hi JP,
    you can also refer the below wiki and blog
    Step-by-step FTP to ABAP Proxy - Process Integration - SCN Wiki
    ABAP Proxy Protocols: Use Cases and Examples
    regards,
    Harish

  • No implementing class registered for the interface (ABAP interface, request

    Hi,
    Proxy has been generated for the Inbound Message interface and i could see the SXMB_MONI entry in Red on the target system.
    I get the error "No implementing class registered for the interface (ABAP interface, request...."
    regards,
    Chaitanya

    Hi Chaitanya,
    Try the below configuration in SXMB_ADM,if you don't have the authorisations to SXMB_MONI ask BASIS guys to do the below activities.
    Go to SXMB_ADM.
    Execute Integration Engine
    EDIT----
    > Change Global configuration data
    select  Role of Business System as Integration Server
    Thanks,
    Amar.

  • Let me know how to Implement Drill throughs in the NW verdion

    Hi,
    I am doing BPC migration project from MS7 to NW7.5.
    There are some Drill throughs are developed in the MS version,And there is no URL in the MS fro this.They stored the data in a table in the backend (SQL)
    Let me know how to Implement Drill throughs in the NW verdion.
    Thanks and Regards
    Krishna

    Hi Krishna,
    Please go through the below link on Drill through in 7.5 NW version.
    http://www.sdn.sap.com/ae28bbe7-899e-4896-8237-f58cc79b34b2/finaldownload/downloadid-e804b270e3c40376a7951c8ed8930e16/ae28bbe7-899e-4896-8237-f58cc79b34b2/irj/scn/go/portal/prtroot/docs/library/uuid/10a56b21-04b9-2d10-a6b7-e0f8732b4142?quicklink=index&overridelayout=true
    Hope it helps.
    Regards,
    Raghu

  • Implementation-specific documentation for the Sun/Oracle Java SE ?

    Hi,
    Some places in the Java SE API specification call for platform-specific documentation. For example, the specification of the method await of class java.util.concurrent.locks.Condition says:
    "Implementation Considerations
    The current thread is assumed to hold the lock associated with this Condition when this method is called. It is up to the implementation to determine if this is the case and if not, how to respond. Typically, an exception will be thrown (such as IllegalMonitorStateException) and the implementation must document that fact. "
    So, implementation-specific documentation is expected to exist in addition to the API specification documentation. Sure, sentences beginning with "Typically..." suggest that that is what the Sun/Oracle reference implementation does, so the behavior of Sun/Oracle implementation can be guessed in many cases... yet sometimes troubling uncertainty remains.
    If implementation-specific documentation for the implementation exists, please let me know.
    I apologize if I chose an inappropriate forum for this question, but there seems to be no forum for discussing documentation arrangements.

    If you want to look at the implementation sepcific documentation, the best place to look is the source.
    The reason the docuementation is written generically is because they want you to write portable code, rather than rely on the specific implementation detail of the one you are using.
    Even if you don't intend to use another vendor, you might want to upgrade in the future and Java 7 or 8 many change its implementations provided it meets the specification.

  • How to implement Change pointers for Purchase order - ME22N - Custom Fields

    Hi Experts,
    Can you please tell me how to implement - Change Pointer for Custom fields in IDOC.
    I am working on IDOC - For purchase order - acknowledgements - in custom screen/tab in ME22N.
    Everything is working fine according to my requirement.
    All i need to know is the process of - Creating/Change - Change pointers for Custom fields.
    1.How to implement change pointers for custom fields.
    2.Can we maintain - Change Document - for custom fields at data element level?
    P.S. - I have browsed many previous - forums before posting a new discussion.
    please share your inputs...
    explaining how to create/implement - change pointers for custom fields will help me .
    Regards,
    Karthik Rali.

    Hi,
    To maintain Change Document for custom field:
    1. Check if "Change document" checkbox is set in data element.
    2. Find Change Document Object for transaction.
       You can use SQL trace - ST05.
       Look there for line with table CDHDR and statement insert values
       (for example for transaction KA02 Change Document Object is KSTAR)
    3. Regenerate update program for this Change Document Object in transaction SCDO
    Change documents for z-fields schould be generated.
    I am not sure about change pointers but they are configured somehow in BD61 and BD50.

  • How to implement Ajax toolkit for SharePoint2013?

    Hi All,
    How to implement Ajax toolkit for SharePoint2013?

    Hi Sam,
    Based on your description,
    I can suggest as follows:
    Use the “SharePoint AJAX 3.5 for 2010 and 2013”
    solution.
    Download URL:
    http://sharepointajax.codeplex.com/
    2.    
    Use the Ajax Control Toolkit with ASP.NET 4.5.
    Download correct version of Ajax Control Toolkit.
    http://ajaxcontroltoolkit.codeplex.com/releases/view/109918
    Add AjaxControlToolkit.dll reference to your project.
    Add Ajax Control Toolkit ScriptManager in master page.
    Register Ajax Control Toolkit namespaces in SharePoint package Designer.
    More information:
    http://timscyclingblog.wordpress.com/2013/03/22/ajaxcontroltoolkit-version-7-0123-with-net-4-5/
    http://sampathnarsingam.blogspot.in/2012/05/how-to-make-ajax-control-toolkit.html
    Please inform me freely if you have any questions.
    Thanks
    Qiao Wei
    TechNet Community Support
    Is it possible to use version AJAX
    Control Toolkit .NET 4.5 along with SharePoint 2013?
    As far as I know with SharePoint we can use only version AjaxControlToolkit(3.0.30930.0). Isnt it?

  • Dimensions for the below cubes.

    Hi All,
    My interview Q was :
    Could you plz provide me the Dimensions for the below Cubes:
    0SD_C03, 0SD_C05, 0SD_C01, 0PUR_C01
    How to find out the dimensions from the help files?
    Any other Dimensions except unit, time n pkg Dim ?? Are there any particular/specific Dim for each of these cubes ?
    Thanks in Adv.

    Hi,
    0sd_c03 having following dimensions by default
    Data Package, Time, Unit, Organization, SD Document Category, Customer, Material, Value Type, Version, Sales Area, Document Classification.
    install your required infocube's from BI content.
    double click on the particular infocube. you can able to see the dimensions available for that infocube's.
    hope this help you
    regards
    harikrishna N

  • Hibernate mapping XML files for the two SQL Server tables below.

    Hello all..,
    Question 1:
    I am working on a project that needs to support a database with an inherited legacy schema that you cannot change. The schema is provided below.Hibernate mapping XML files for the two SQL Server tables below. Please provide those two XML files. Assume some hypothetical package and class names. Assume that no "fancy" stuff such as lazy initialization, optimistic locking etc is needed at this time.
    CREATE TABLE [SURVEY_ANSWERS] (
    [ANSWER_ID] [int] IDENTITY (1,1) NOT NULL,
    [QUESTION_ID] [int] NOT NULL,
    [POSITION] [int] NULL,
    [TEXT] [varchar](350) NULL
    CREATE TABLE [dbo].[SURVEY_QUESTIONS] (
          [QUESTION_ID] [int] IDENTITY (1, 1) NOT NULL ,
          [TEXT] [varchar] (350) NULL
    GO
    ALTER TABLE SURVEY_ANSWERS
    ADD CONSTRAINT pk_SURVEY_ANSWERS PRIMARY KEY(ANSWER_ID,QUESTION_ID);
    ALTER TABLE [dbo].[SURVEY_QUESTIONS] ADD
           PRIMARY KEY  CLUSTERED
                [QUESTION_ID]
    GO
    ALTER TABLE [dbo].[SURVEY_ANSWERS] ADD
           FOREIGN KEY
                [QUESTION_ID]
          ) REFERENCES [dbo].[SURVEY_QUESTIONS] (
                [QUESTION_ID]
          )Question 2:
    Assume that you are working on a project developing, say, a banking application. You are the Architect and thinking that Hibernate ORM should be used for the entire access to the relational database. As usual, you have created (or auto-generated) a set of HBM XML files as well as POJOs for which you define the mappings. Assume now that a new requirement has just popped up. The system needs to be able to import new bank accounts and user information in bulk from a very large XML file at once and store it in the database. Assume the XML file contains all necessary information to populate fields in database tables. As performance is very important for this operation. Given this description, how would you approach the problem?
    Please describe briefly.
    -Thanks and regards
    Praveen Soni

    You're not fooling anyone Dennis_Mox. But nice try.Jeez, man. Mail me at denismox[at]yandex.ru, I will show you that exact test, dammit.

Maybe you are looking for

  • How do you minimize the window when the top of the page is above screen height in ubuntu 12.04, so I can't see the tabs, let alone using the normal minimize

    Hi there, every now and then when i maximixe or minimize a window. The top of the window is above the screen so I am unable to see the tabs or anything above the address bar, is the a way to minimize using the menu, or a configuration file I can alte

  • Get weeks based on start date

    Hi , i need a query that will determine the weeks based on start date. if the table consists of: vDate vAmount 06/25/2007 100 06/27/2007 200 07/04/2007 400 If one enters start date as 6/25/2007 , amounts should be broken out in 7 day increments. Resu

  • IPhone replacement?

    Hello, back in November of '08 i bought the iPhone 3G. well, a few months and a couple dings later, my iphone is in dire need of a replacement. Unfortunately, I am only 17, so my dad's name is on the contract, not mine. would i still be able to get t

  • How to install report server as service in windows

    OS : windows XP oracle 10G isuite Every time I am restarting my machine I have to start the report server using command rwserver server=repserver10G start in command prompt. How to install the the report server as service in windows? so that it can b

  • HomeSite+ bundled with Dreamweaver MX 2004

    I bought Dreamwreaver when it was owned by Macromedia. At that time it was bundled with Flash MX 2004 and HomeSite+. This last piece of software turned out to be a very handy code editor which I have used ever since. As Windows versions came and went