SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

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

Shannon Sears
Starting Member

Canada
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.id, Order.Itemcode, Order.Rowtotal, Order.Date, Order.Status

From Ship Table:
Ship.Id, Ship.Baseid (same as Order.id), 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.

tkizer
Almighty SQL Goddess

USA
35951 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
http://weblogs.sqlteam.com/tarad/

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

visakh16
Very Important crosS Applying yaK Herder

India
52249 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  
 New 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.06 seconds. Powered By: Snitz Forums 2000