Please start any new threads on our new site at We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Query for Totals from 2 Tables
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Shannon Sears
Starting Member

1 Posts

Posted - 11/28/2009 :  16:44:12  Show Profile  Reply with Quote
I need a query to generate a list with the following fields:
Itemcode, Sum(Order.Rowtotal), Sum(Ship.Rowtotal) for the Period > '20091101' And < '20091130' And where Orderstatus = 'C'

From Order Table:, Order.Itemcode, Order.Rowtotal, Order.Date, Order.Status

From Ship Table:
Ship.Id, Ship.Baseid (same as, Ship.Itemcode, Ship.Rowtotal, Ship.Date

Order table includes all orders.
Ship Table only includes records for items that have shipped.

Any help would be appreciated.

Almighty SQL Goddess

38200 Posts

Posted - 11/28/2009 :  17:06:05  Show Profile  Visit tkizer's Homepage  Reply with Quote
Show us what you have so far, and we'll help fix it.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."
Go to Top of Page

Very Important crosS Applying yaK Herder

52326 Posts

Posted - 11/29/2009 :  12:48:26  Show Profile  Reply with Quote
just do a LEFT JOIN with ship table and group on Itemcode and apply sum over required fields.
Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.02 seconds. Powered By: Snitz Forums 2000