sql - Adding Total Sales -
I'm having trouble getting the total number of items sold. The script below shows me total sales but their short does not. I got to tell this, but it was listing duplicate invoices so I "separate" before the invoice. I do not know where I'm messing with. Note that I do not have any previous SQL training, I have only got it from reading the questions of other readers. Please help. thank you in advanced.
select sh.invoice_no, sr.item_id, sr.item_desc, sr.last_sale, sr.SQ, sr.DQ, sr.AQ, sr.VQ, sr pq, sr.iQOH , Sr.avg_MAC, si.cost, sr.PT, item, SUM (sh.qty_shipped) as QTY_Shipped from iml_view_item_stock_review_nh to si.item_id sr include sr.item_id = si.item_id interi as C Include as p21_view_inventory_supplier as sh on Sr1item_id = sh.item_id p21_sales_history_view where (sr.item_id 'IEI%') and (sr.PT = 'R') and (sh.invoice_date & gt; Convert (DATETIME, ' 2013-10-17 00:00:00 ', 102)) GROUP by sr.item_id, sr.item_desc, sr.last_sale, sr.SQ, sr.DQ, sr.AQ, sr.VQ, sr.PQ, sr .iQOH, sr Avg_MAC, CIOST, SRPTT, CIITM_I D, SAREVICE_NO
Below is a sample of data. I have left some other columns. I hope it will help.
| Invoice_no Item_ID | QTY_Shipped | | | ----------------------------------------- | | 1000616 | IEEE 0803000F. 4 | | 1001289 | IEEE 0803000F. 2 | | 1018242 | IEEE 0803000F. 2 | | 1001224 | IEI212I | 2 | | 1002265 | IEI212I | 2 | | 1003547 | IEI212I | 2 |
Expected output is something like this:
| Item_ID | QTY_Shipped | | | -------------- | -------------- | | IEEE 0803000F. 8 | | IEI212I | 6 |
Sorry if I do not have much knowledge, my company is sending me to be trained and certified in January and soon I will help others. Thanks in advance.
It was found that my query was right at the right time I was just shocked by the data
select sr.item_id, sr.item_desc, sr.last_sale, sr.SQ, sr.DQ, sr.AQ, sr.VQ, sr.PQ, sr.iQOH, sr.avg_MAC, CIOOST, SR INV JOIN P 21_view_ as SRPT, CIITM_ID Asim (SAP), SUM (SATIPPP), as an IML_view_item_stock_review_nh as inventory_planer SI.itm_id = citm_id Join Inner P21_sales_ Shr.item_id = sh.item_id where history_view is where (sr.item_id 'IEI%') and (sr.PT = 'R') and (sh.invoice_date & gt; DATEADD (year, -1, GETDATE) ) GROUP by sr.item_id, sr.item_desc, sr.last_sale, sr.SQ, sr.DQ, sr.AQ, sr.VQ, sr.PQ, sr.iQOH, sr.avg_MAC, si.cost, sr.PT , Si.item_id
Comments
Post a Comment