|
-
September 17th, 2009, 04:09 AM
#1
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
-
September 17th, 2009, 02:48 PM
#2
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|