sql server - SQL Help - Sales by State (SAP Business One) -


If someone can help me in my query then I try to use to remove sales information from my database I am here. I am trying to create a report to show all the sales by the state. I have come across this code along with the need to include wareshouses (from the sale of each state and until it is close to that I What is needed is not to go completely.

T1 [WhsCode]) was sold from that stock I need to include in each column (I know that you can press Ctrl And without any column You can click to get the sum of them, but want to automatically show them on the final report). ? Anyone can help

The query is up to now:

  'State to send bill' as T0.State1, (sum (T1.DocTotal Selection) Select from OINV to T1 (NOLOCK) INNER OCRD T2 on T2. ​​CardCode = T 1. CardDod where month (T.DOCKET) = 1 and T2. State 1 = T. TT1 and year (T.DOCKET) = year (GATEDATE)) with AS ONVI T1 (NOLKAC) INNER join ONIRD T2 ON T2. CardCode = T1. CardDod where month (T1DCDD) = 2 and T2. State 1 = T.State1 and YEAR (T.DOCKET) = 'FEB Amit' as the year (GETDATE ()), (Select SUM (T1.DocTotal) with OINV T1 (NOLOCK) INNER OCRD T Include 2 on the T2 cardcod = t 1. Where the CardDod is the month (T1.DOCDATE) = 3 and T2.State1 = T0.State1 and year (T1.DOCDATE) = year (GETDATE ()) as' Join March 1, (T1.DocTotal) with OINV T1 (NOLOCK) Insiders OCRD T2 on T2.CardCode = T1.CardCode Where month (T1.DOCDATE) = 4 and T2.State1 = 'T0.State1 and year (T1.DOCDATE) = year (GETDATE ())) as' April amount', (A Join T2.CardCode = T1.CardCode OCRD T2 with OINV T1 (NOO CK) interiors from IUM (T1 doctor total) where month (T1.DOCDATE) = 5 and T2.State1 = T0. State1 and year (T1.DOCDATE) = 'May amount' (as in GETDATE)), (Open TM (T1 Ductal) with ONVI TON (NOLOCAC) INOR OCRD T2 ON T2 CardDod = T. CardDod where month (T.DOCDET) = 6 and T.State1 = T.State1 and year (T1DOCAT) =) (June) (Janet AMT), (Select SM (T1. Doktolal) is included in the OINVi T1 (NOLOCAC) Inner OCRD T2 on T2. CardDod = T1. 'July amount', (sum (T1.DocTotal) OINVT as the cardodod where MONST (T1 docdett) = 7 and T2.State1 = T0.State1 and year (T1.DOCDATE) = year (GETDATE ())) Join 1 (NOLOCK) interiors with 1 T2.CardCode = T1.CardCode on OCRD T2 where month (T1.DOCDATE) = 8 and T2.State1 = T0.State1 and year (T1.DOCDATE) = year (GETDATE ('))) As' August amount', (Select Yoga (T1.DocTotal) with OINV T1 (NOLOCK) INNER OCRD T2 on T2. ​​CardCode = T 1. CardDod where month (T 1.DCDD) = 9 and T2. State 1 = T. TCECT 1 and year (T.DOCKET) = 'SEP MT' as the year (GETDATE ())), (Select SUM (T1 doccolle) with ONV T1 (NOLOCAC) included in INR OCRD T2 on T2 CardCode = T. CardDod where month (T.DOCADET) = 10 and T2. State 1 = T.State 1 and year (T.DCDAT) = year (GETDATE)) 'OCT Amm' As, (Select SUM (T1 Doktolal) with ONV T1 (NOLokac) Inner OCRD T2 on T2, G. CardDod = T1 Cardad D 'month month (T1 .DOCDATE) = 11 and T2.State1 = T0.State1 and year (T1.DOCDATE) = year (GETDATE ())) as' November amount', (sum (T1.DocTotal selection) Do not include OINV T1 with (NOLOCK) Insider OCRD T2 but T2.CardCode = T1.CardCode where month (T1.DOCDATE) = 12 and T2.State1 = T0.State1 and year (T1.DOCDATE) = Year (GETDATE ()) as 'December amount' from dbo .OCRD T0 Left dbo.OINV T1 join T1.CardCode = T0.CardCode Group T0.State1 by order T0.State1   

but use the SQL axis:

  - Select a row and five columns from the table with ['] [0], [1], [2], [3], [4] with' AverageCost 'as the cost_Sorted_By_Production_Days (selection da ysToManufacture, Production.Product From StandardCost as SourceTable Pivot (StandardCost) in DaysToManufacture ([0], [1], [2], [3], [4]) as PivotTable;    

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -