Trying to join sales numbers - having trouble

I'm very new to Sql. I'm trying to join two queries into one. They each work independently, but when I try to combine them I get duplication - the same part is listed numerous times. I know it's something simple, but I can't figure it out. Any help would be much appreciate.
Query #1 - Pulls sales for last 30 days*
(select sitecode, physical_warehouse, partno, sum(qty_used) as qty_used_1_month
from partsusage
where ((date_usage > add_months(trunc(sysdate), -1))
and (date_usage <= trunc(sysdate)))
group by sitecode, physical_warehouse, partno) SOLD
Query #2 - Lists the site, part #, and order type._
SELECT ORDER_PARTS.SITECODE_SUPPLIER as orig_sitecode_ship_from
, order_parts.partno
,order_header.order_sub_type,
FROM ORDER_HEADER, ORDER_PARTS
Queries combined:*
SELECT ORDER_PARTS.SITECODE_SUPPLIER as orig_sitecode_ship_from
, order_parts.partno
,order_header.order_sub_type,
FROM ORDER_HEADER, ORDER_PARTS
, (select sitecode, physical_warehouse, partno, sum(qty_used) as qty_used_1_month
from partsusage
where ((date_usage > add_months(trunc(sysdate), -1))
and (date_usage <= trunc(sysdate)))
group by sitecode, physical_warehouse, partno) SOLD

Looks like a lovely Cartesian join to me ... your WHERE clause contains filters but no joins.
Run the demos here:
http://www.morganslibrary.org/library.html
under joins and bookmark the library page for future reference.

Similar Messages

Maybe you are looking for

  • How can I get Minecraft onto my Macbook Pro?

    How can I get Minecraft onto my Macbook Pro? It is 15 inch Retina display, and it is Version 10.9.1 . I download the game, log in and press play, but as soon as it finishes loading, the blue bar goes away and nothing else happens! It goes from this:

  • I have problem in this unzip java codes

    hi all,I have problem in this unzip java codes,I think either the pathway that i put C:.......is wrong or the codes are wrong because when i run it, the zipped folder is not unzipped. So anyone has another set of example or know how to correct it? Th

  • Info about BDCPS table

    Hi Experts, I needed this  bit of information about change pointers. Can someone please tell me how the column 'ALE processing indicator' in BDCPS table  gets upadted? Also does BDCP and BDCPS table get updated simultaneousy whenever there is any cha

  • Hi What are topics involved in Interfaces,Conversions in ABAP?

    Please Explain me. Thank u in advance

  • How to move track layer in timeline so all keyframes move together?

    Hi all, I have a simple project with various text layers moving up from the bottom and gently landing in position. There is also a style face blur going on so the text starts out blurred and becomes clear as the text lands. As I duplicate a layer in