Unoffical empeg BBS

Quick Links: Empeg FAQ | RioCar.Org | Hijack | BigDisk Builder | jEmplode | emphatic
Repairs: Repairs

Topic Options
#341550 - 26/01/2011 12:52 SQL Help
tahir
pooh-bah

Registered: 27/02/2004
Posts: 1919
Loc: London
I'm trying to join 2 tables which hold values different;y, ol holds them at a PER STYLE level, sa holds them at a PER STYLE/SIZE/COLOUR level, how do I show the sum of the quantity field in sa?

Sql Query:
select
ol.Order_Number as SO, ol.Order_Line_Number as Line, ol.Style, ol.Customer,
CONVERT(varchar(10), CONVERT(datetime, ol.Date_Created), 103) as Entered,
CONVERT(varchar(10), CONVERT(datetime, ol.Delivery_Date), 103) as Delivery_Date,
ol.Sales_Price as Price, ol.Total_Ordered as Ordered, ol.Total_Outstanding as Outstanding, ol.Total_Cancelled as Cancelled, ol.PO_Number as PO,
ol.Customer_s_Order_Number as CustPO
from order_lines11 as ol
left outer join stk_aud5 as sa on ol.PO_Number = sa.Order_No and ol.Style = sa.Style
where
Total_Outstanding > '0'
and ol.Delivery_Date < '20110101'
and ol.New_Order_Type = 'F'
order By ol.Customer, ol.Order_Number 



As with most techy things I'm not the sharpest tool, so would appreciate a simple solution (if poss)


Edited by tahir (26/01/2011 12:58)

Top
#341553 - 26/01/2011 14:37 Re: SQL Help [Re: tahir]
wfaulk
carpal tunnel

Registered: 25/12/2000
Posts: 16706
Loc: Raleigh, NC US
What are you wanting a sum of, exactly? You want to get the sum of sa.quantity for each sa.style, ignoring the size and color? Filtered by the WHERE clause in your quoted SELECT statement?
_________________________
Bitt Faulk

Top