Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
rlull
Starting Member
39 Posts |
Posted - 2006-07-06 : 10:44:59
|
| How can I return the following information? The aggregate function is throwing it off. Is there a better way? Thanks.selectOrders.OrderID,Orders.OrderDateTime,Orders.BillLastName,Orders.BillCompany,Orders.SubtTotal,Orders.DiscountTotal,Orders.Tax,Orders.ShipCost,Orders.OrderTotal,Sum(Orders.SubTotal - Orders.DiscountTotal) as ActualMerchandiseCustomers.SalesIDfrom Ordersjoin Customerson Orders.CustID = Customers.CustIDwhere OrderDateTime >= '6/1/2006'and OrderDateTime <= '6/30/2006'order by SalesID, OrderDateTime |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2006-07-06 : 10:51:14
|
| You forgot to add GROUP BY clause...selectOrders.OrderID,Orders.OrderDateTime,Orders.BillLastName,Orders.BillCompany,Orders.SubtTotal,Orders.DiscountTotal,Orders.Tax,Orders.ShipCost,Orders.OrderTotal,Sum(Orders.SubTotal - Orders.DiscountTotal) as ActualMerchandiseCustomers.SalesIDfrom Ordersjoin Customerson Orders.CustID = Customers.CustIDwhere OrderDateTime >= '6/1/2006'and OrderDateTime <= '6/30/2006'group byOrders.OrderID,Orders.OrderDateTime,Orders.BillLastName,Orders.BillCompany,Orders.SubtTotal,Orders.DiscountTotal,Orders.Tax,Orders.ShipCost,Orders.OrderTotal,Customers.SalesIDorder by SalesID, OrderDateTimeHarsh AthalyeIndia."Nothing is Impossible" |
 |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
|
|
|
|
|