Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 2779

Re: File for Intrastat Declaration !

$
0
0

I forgot to ask, do you use intrastat for import, export or both ?

 

Never mind, I was looking at an old version...

 

Here it is:

 

SELECT U_cutomid, FirmName, Country,

   cast(SUM(Nettopaino) as int) AS Nettopaino,

   cast(SUM(Toinen_paljous) as int) AS 'Paljous2',

   cast(SUM(Laskutusarvo) as int) AS Laskutusarvo

   FROM (SELECT T2.U_cutomid, OMRC.FirmName, T3.Country, (SUM(T2.BWeight1 * T1.Quantity)/1000) AS Nettopaino, SUM(T2.NumInBuy * T1.Quantity) AS 'Toinen_paljous', SUM(T1.Price * T1.Quantity) AS Laskutusarvo

         FROM OPCH T0 INNER JOIN

              PCH1 T1 ON T0.DocEntry = T1.DocEntry INNER JOIN

              OITM T2 ON T1.ItemCode = T2.ItemCode INNER JOIN

              OMRC ON T2.FirmCode = OMRC.FirmCode LEFT OUTER JOIN

              OCRD T3 ON T2.CardCode = T3.CardCode INNER JOIN

              OCRY ON T3.Country = OCRY.Code

         WHERE (T0.DocDate  BETWEEN @fromDate AND @toDate) AND (T2.U_cutomid IS NOT NULL) AND (T3.Country <> 'FI') AND OCRY.IsEC = 'Y'

         GROUP BY T3.Country, T2.FirmCode, T2.U_cutomid, T1.Dscription, T1.ItemCode, T2.BuyUnitMsr, OMRC.FirmName) DERIVEDTBL

   GROUP BY U_cutomid, FirmName, Country

   HAVING SUM(Laskutusarvo) >= 1

 

Regards,

Johan


Viewing all articles
Browse latest Browse all 2779

Trending Articles