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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Group by issues

Author  Topic 

jamez36
Starting Member

3 Posts

Posted - 2006-01-19 : 18:53:12
I need to get the sum of I.QtyRcvd and have that value returned for each matching record, right now it only returns the record that has values for I.QtyRcvd <> 0.

SQL = "SELECT P.Quantity as Qty, " & vbCrLf _
& "P.ItemID, " & vbCrLf _
& "P.VendorCode, " & vbCrLf _
& "P.Descr as Description, " & vbCrLf _
& "P.UnitPrice as Price, " & vbCrLf _
& "Amount = 0.0, " & vbCrLf _
& "Freight = 0.0, " & vbCrLf _
& "Rcvd = 0, " & vbCrLf _
& "sum(I.QtyRcvd) as Ship" & vbCrLf _
& "FROM PurchaseOrderItems P, ReceivedItems I, Received R" & vbCrLf _
& "WHERE I.ItemID = P.ItemID AND P.POID = R.POID AND R.IntRcdID = I.PRID AND P.POID = " & txtPO.Text & vbCrLf _
& "GROUP BY P.Quantity, P.ItemID, P.VendorCode, P.Descr, P.UnitPrice"

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-01-20 : 00:25:00
Post some sample data and the result you want

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -