CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 2009
    Posts
    1

    Post how to use simple method to join two aggregate results?

    Dear experts,

    I want to have the simplest method to join two aggregated results to a newly table. But I don't want to use stored procedure or function, don't want to use temporary tables to do so. Do you have any method to join two result sets with a simplest method?

    table 1.
    ====
    select distinct a.CProduct_IDM + '-' + CProduct_IDC + '-' + CProduct_IDS as CProduct_ID, Packing_ID
    from tabWarehouseCCProduct a
    go

    table 2.
    =======
    select b.CProduct_IDM + '-' + b.CProduct_IDC + '-' + b.CProduct_IDS as CProduct_ID, WHC_ID,
    sum(b.WHCCP_Qty) as WHCCP_Qty_TTL
    from tabWarehouseCCProduct b
    group by b.CProduct_IDM + '-' + b.CProduct_IDC + '-' + b.CProduct_IDS, b.WHC_ID
    go

    want to have a new table:
    CProductID, WHC_ID, WHCPP_Qty_TTL, Packing_ID
    ====================================

    Thanks.


    Edit by admin: no contact info permitted on the forum, thank you

  2. #2
    Join Date
    Jun 2004
    Location
    Kashmir, India
    Posts
    6,808

    Re: how to use simple method to join two aggregate results?

    I am not sure which database you are using. In case of SQL you could use Union to combine the results from the two queries. Look up the documentation of the database that you are using, there would be plenty of examples similar to Union.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured