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 |
|
researcy
Starting Member
6 Posts |
Posted - 2007-02-07 : 12:27:17
|
| I,m pulling cost of goods and a supplier number from multiple lines of invoices. The problem is that I get more than 64000 lines which I can't support in excel. (need excel to finish other computations). What I want is a way to total all of the COG for each supplier. Is there a way to do that and then return it to excel? I know there is a SUM command but I'm not sure how to write it in. Here's my script. Any ideas?SELECT DISTINCT p21_view_invoice_hdr.sales_location_id, p21_view_invoice_line.item_id, p21_view_invoice_line.cogs_amount, p21_view_invoice_line.supplier_id, p21_view_invoice_hdr.invoice_dateFROM Prophet21.dbo.p21_view_invoice_hdr p21_view_invoice_hdr, Prophet21.dbo.p21_view_invoice_line p21_view_invoice_line, Prophet21.dbo.p21_view_supplier p21_view_supplierWHERE p21_view_invoice_hdr.invoice_no = p21_view_invoice_line.invoice_no AND p21_view_invoice_line.supplier_id = p21_view_supplier.supplier_id AND ((p21_view_invoice_hdr.sales_location_id=?) AND (p21_view_invoice_hdr.invoice_date Between ? And ?)) |
|
|
AndrewMurphy
Master Smack Fu Yak Hacker
2916 Posts |
Posted - 2007-02-08 : 04:57:57
|
| select suppliercode, sum(invoiceamount)from invoicestablegroup by suppliercodeis the sort of thing you need.Any chance you could provide some sample input data (+ matching expected output)? |
 |
|
|
|
|
|