V_Verkauf_queries.sql 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  1. CREATE
  2. OR
  3. ALTER VIEW [load].[current_date_Prognose]
  4. AS
  5. SELECT --[Bundeslaender Id] AS [Bundeslaender Id],
  6. [Datum] AS [Invoice Date],
  7. --[Wochentage Id] AS [Wochentage Id],
  8. [Arbeitstag Mofr] AS [Arbeitstag Mofr],
  9. [Zaehler Mofr] AS [Zaehler Mofr],
  10. [Summe Mofr] AS [Summe Mofr],
  11. [Arbeitstag Mosa] AS [Arbeitstag Mosa],
  12. [Zaehler Mosa] AS [Zaehler Mosa],
  13. [Summe Mosa] AS [Summe Mosa],
  14. [Feiertage Id] AS [Feiertage Id],
  15. --[Jahr] AS [Jahr],
  16. [Arbeitstag Nr Jahr] AS [Arbeitstag Nr Jahr],
  17. [Gesamt Arbeitstage] AS [Gesamt Arbeitstage]
  18. FROM [export_csv].[current_date_Prognose]
  19. GO
  20. CREATE
  21. OR
  22. ALTER VIEW [load].[NW_GW_VK_TIM]
  23. AS
  24. SELECT --[No] AS [No],
  25. --[Name] AS [Name],
  26. --[Account Type] AS [Account Type],
  27. --[Department Code] AS [Department Code],
  28. --[Make Code] AS [Make Code],
  29. --[Income Balance] AS [Income Balance],
  30. --[Entry No] AS [Entry No],
  31. --[G L Account No] AS [G L Account No],
  32. --[Posting Date] AS [Posting Date],
  33. --[Document Type] AS [Document Type],
  34. --[Document No] AS [Document No],
  35. --[Description] AS [Description],
  36. --[Amount] AS [Amount],
  37. --[Bal Account No] AS [Bal Account No],
  38. --[User Id] AS [User Id],
  39. --[Source Code] AS [Source Code],
  40. --[Quantity] AS [Quantity],
  41. --[Debit Amount] AS [Debit Amount],
  42. --[Credit Amount] AS [Credit Amount],
  43. --[Document Date] AS [Document Date],
  44. --[Source Type] AS [Source Type],
  45. --[Source No] AS [Source No],
  46. --[No Series] AS [No Series],
  47. --[Branch Code] AS [Branch Code],
  48. --[Main Area] AS [Main Area],
  49. --[Vin] AS [Vin],
  50. --[Book No] AS [Book No],
  51. --[Veh Source Code] AS [Veh Source Code],
  52. --[Betrag] AS [Betrag],
  53. --[Vin_Vehicle] AS [Vin_Vehicle],
  54. --[Vehicle Status] AS [Vehicle Status],
  55. --[Model_ori] AS [Model_ori],
  56. --[Type] AS [Type],
  57. --[Class] AS [Class],
  58. --[Model No] AS [Model No],
  59. [Hauptbetrieb] AS [Hauptbetrieb],
  60. --[Standort_alt] AS [Standort_alt],
  61. --[Make Code_Vehicle] AS [Make Code_Vehicle],
  62. --[Fabrikat_ori] AS [Fabrikat_ori],
  63. [Model] AS [Model],
  64. --[Market Segment Code] AS [Market Segment Code],
  65. [Modellbez] AS [Modellbez],
  66. [Fahrzeugart] AS [Fahrzeugart],
  67. --[Vat Prod Posting Group] AS [Vat Prod Posting Group],
  68. [Fahrzeugtyp] AS [Fahrzeugtyp],
  69. [FZG] AS [FZG],
  70. --[Fahrzeugtyp_alt] AS [Fahrzeugtyp_alt],
  71. --[Location Code] AS [Location Code],
  72. [VB_Einkauf] AS [VB_Einkauf],
  73. --[Purchase Receipt Date] AS [Purchase Receipt Date],
  74. [Standtage_ori] AS [Standtage_ori],
  75. --[Standtagestaffel] AS [Standtagestaffel],
  76. --[Initial Registration] AS [Initial Registration],
  77. --[EZ/Eingang] AS [EZ/Eingang],
  78. --[Polster] AS [Polster],
  79. --[Farbe] AS [Farbe],
  80. --[Einsatz_ori] AS [Einsatz_ori],
  81. --[Heute] AS [Heute],
  82. --[Fahrzeugstatus] AS [Fahrzeugstatus],
  83. --[FZG-Liste] AS [FZG-Liste],
  84. --[Anzahl] AS [Anzahl],
  85. [Standtage] AS [Standtage],
  86. --[Inventory Posting Group] AS [Inventory Posting Group],
  87. --[Date Of Sale] AS [Date Of Sale],
  88. [Invoice Date] AS [Invoice Date],
  89. --[Customer No] AS [Customer No],
  90. --[No_Customer] AS [No_Customer],
  91. --[Name_Customer] AS [Name_Customer],
  92. [Kunde] AS [Kunde],
  93. --[Customer Type] AS [Customer Type],
  94. [Kundenart] AS [Kundenart],
  95. --[Old Customer No] AS [Old Customer No],
  96. --[No_Vorbesitzer] AS [No_Vorbesitzer],
  97. --[Name_Vorbesitzer] AS [Name_Vorbesitzer],
  98. --[Vorbesitzer] AS [Vorbesitzer],
  99. --[Engine Code] AS [Engine Code],
  100. --[Motor Code] AS [Motor Code],
  101. --[Geschäftsart] AS [Geschäftsart],
  102. --[FZG_Liste_1_ori] AS [FZG_Liste_1_ori],
  103. --[FZG_Liste_2] AS [FZG_Liste_2],
  104. --[FZG_Liste_3] AS [FZG_Liste_3],
  105. --[FZG_Liste_4] AS [FZG_Liste_4],
  106. [Erlös] AS [Erlös],
  107. [Einsatz] AS [Einsatz],
  108. --[EK Fahrzeug] AS [EK Fahrzeug],
  109. [Bonus] AS [Bonus],
  110. [int. Kosten] AS [int. Kosten],
  111. --[Current Branch Book No] AS [Current Branch Book No],
  112. --[Current Book No] AS [Current Book No],
  113. --[Summe EK-FZG] AS [Summe EK-FZG],
  114. [Fabrikat] AS [Fabrikat],
  115. --[Buchnummer gleich_ja_nein] AS [Buchnummer gleich_ja_nein],
  116. --[Menge1] AS [Menge1],
  117. --[Menge2] AS [Menge2],
  118. --[Menge3] AS [Menge3],
  119. --[Menge4] AS [Menge4],
  120. --[VIN + PostingDate] AS [VIN + PostingDate],
  121. --[Summe Menge4] AS [Summe Menge4],
  122. --[Menge_2_test] AS [Menge_2_test],
  123. --[Menge3_test] AS [Menge3_test],
  124. --[Menge4_test] AS [Menge4_test],
  125. --[Fahrzeugart_Schmidt] AS [Fahrzeugart_Schmidt],
  126. --[Salespers Purch Code_VLE] AS [Salespers Purch Code_VLE],
  127. --[Code_für_VEH_Ledger_Entry] AS [Code_für_VEH_Ledger_Entry],
  128. --[Name_für_VEH_Ledger_Entry] AS [Name_für_VEH_Ledger_Entry],
  129. [Verkäufer] AS [Verkäufer],
  130. --[FZG_Liste_1_falsch] AS [FZG_Liste_1_falsch],
  131. --[FZG_Liste_0_ori] AS [FZG_Liste_0_ori],
  132. --[FZG_Liste_1] AS [FZG_Liste_1],
  133. --[FZG_Liste_0] AS [FZG_Liste_0],
  134. [Beleg] AS [Beleg],
  135. --[Standort_FIBU] AS [Standort_FIBU],
  136. --[Fahrzeugart_neu] AS [Fahrzeugart_neu],
  137. [Standort] AS [Standort],
  138. --[Summe_Betrag] AS [Summe_Betrag],
  139. --[Country Code_Kunde] AS [Country Code_Kunde],
  140. --[Vat Bus Posting Group_Kunde] AS [Vat Bus Posting Group_Kunde],
  141. --[FZG_Liste_5_ori] AS [FZG_Liste_5_ori],
  142. --[Customer Group Code] AS [Customer Group Code],
  143. --[FZG_Liste_5] AS [FZG_Liste_5],
  144. --[FZG_Liste_6] AS [FZG_Liste_6],
  145. --[FZG_Liste_7] AS [FZG_Liste_7],
  146. [FZG_Detail] AS [FZG_Detail],
  147. [No] + ' - ' + [Name] AS [Konto],
  148. --[Anz. Sätze] AS [Anz. Sätze],
  149. [Menge_final] AS [Menge_final],
  150. --[No_Item] AS [No_Item],
  151. --[Description_Item] AS [Description_Item],
  152. --[Vehicle Type Code_Item] AS [Vehicle Type Code_Item],
  153. --[Modell_zwischen] AS [Modell_zwischen],
  154. --[Vehicle Category Code] AS [Vehicle Category Code],
  155. --[Summe Erlös FZG] AS [Summe Erlös FZG],
  156. --[Erlöse FZG] AS [Erlöse FZG],
  157. --[Modell_final] AS [Modell_final]
  158. FROM [export_csv].[NW_GW_VK_TIM]
  159. GO
  160. CREATE
  161. OR
  162. ALTER VIEW [load].[NW_GW_VK_TIM_Grosskd]
  163. AS
  164. SELECT --[No] AS [No],
  165. --[Name] AS [Name],
  166. --[Account Type] AS [Account Type],
  167. --[Department Code] AS [Department Code],
  168. --[Make Code] AS [Make Code],
  169. --[Income Balance] AS [Income Balance],
  170. --[Entry No] AS [Entry No],
  171. --[G L Account No] AS [G L Account No],
  172. --[Posting Date] AS [Posting Date],
  173. --[Document Type] AS [Document Type],
  174. --[Document No] AS [Document No],
  175. --[Description] AS [Description],
  176. --[Amount] AS [Amount],
  177. --[Bal Account No] AS [Bal Account No],
  178. --[User Id] AS [User Id],
  179. --[Source Code] AS [Source Code],
  180. --[Quantity] AS [Quantity],
  181. --[Debit Amount] AS [Debit Amount],
  182. --[Credit Amount] AS [Credit Amount],
  183. --[Document Date] AS [Document Date],
  184. --[Source Type] AS [Source Type],
  185. --[Source No] AS [Source No],
  186. --[No Series] AS [No Series],
  187. --[Branch Code] AS [Branch Code],
  188. --[Main Area] AS [Main Area],
  189. --[Vin] AS [Vin],
  190. --[Book No] AS [Book No],
  191. --[Veh Source Code] AS [Veh Source Code],
  192. --[Betrag] AS [Betrag],
  193. --[Vin_Vehicle] AS [Vin_Vehicle],
  194. --[Vehicle Status] AS [Vehicle Status],
  195. --[Model_ori] AS [Model_ori],
  196. --[Type] AS [Type],
  197. --[Class] AS [Class],
  198. --[Model No] AS [Model No],
  199. [Hauptbetrieb] AS [Hauptbetrieb],
  200. --[Standort_alt] AS [Standort_alt],
  201. --[Make Code_Vehicle] AS [Make Code_Vehicle],
  202. --[Fabrikat_ori] AS [Fabrikat_ori],
  203. [Model] AS [Model],
  204. --[Market Segment Code] AS [Market Segment Code],
  205. [Modellbez] AS [Modellbez],
  206. [Fahrzeugart] AS [Fahrzeugart],
  207. --[Vat Prod Posting Group] AS [Vat Prod Posting Group],
  208. [Fahrzeugtyp] AS [Fahrzeugtyp],
  209. [FZG] AS [FZG],
  210. --[Location Code] AS [Location Code],
  211. [VB_Einkauf] AS [VB_Einkauf],
  212. --[Purchase Receipt Date] AS [Purchase Receipt Date],
  213. [Standtage_ori] AS [Standtage_ori],
  214. --[Standtagestaffel] AS [Standtagestaffel],
  215. --[Initial Registration] AS [Initial Registration],
  216. --[EZ/Eingang] AS [EZ/Eingang],
  217. --[Polster] AS [Polster],
  218. --[Farbe] AS [Farbe],
  219. --[Einsatz_ori] AS [Einsatz_ori],
  220. --[Heute] AS [Heute],
  221. --[Fahrzeugstatus] AS [Fahrzeugstatus],
  222. --[FZG-Liste] AS [FZG-Liste],
  223. --[Anzahl] AS [Anzahl],
  224. [Standtage] AS [Standtage],
  225. --[Inventory Posting Group] AS [Inventory Posting Group],
  226. --[Date Of Sale] AS [Date Of Sale],
  227. [Invoice Date] AS [Invoice Date],
  228. --[Customer No] AS [Customer No],
  229. --[No_Customer] AS [No_Customer],
  230. --[Name_Customer] AS [Name_Customer],
  231. [Kunde] AS [Kunde],
  232. --[Customer Type] AS [Customer Type],
  233. [Kundenart] AS [Kundenart],
  234. --[Old Customer No] AS [Old Customer No],
  235. --[No_Vorbesitzer] AS [No_Vorbesitzer],
  236. --[Name_Vorbesitzer] AS [Name_Vorbesitzer],
  237. --[Vorbesitzer] AS [Vorbesitzer],
  238. --[Engine Code] AS [Engine Code],
  239. --[Motor Code] AS [Motor Code],
  240. --[Geschäftsart] AS [Geschäftsart],
  241. --[FZG_Liste_1_ori] AS [FZG_Liste_1_ori],
  242. --[FZG_Liste_2] AS [FZG_Liste_2],
  243. --[FZG_Liste_3] AS [FZG_Liste_3],
  244. --[FZG_Liste_4] AS [FZG_Liste_4],
  245. [Erlös] AS [Erlös],
  246. [Einsatz] AS [Einsatz],
  247. --[EK Fahrzeug] AS [EK Fahrzeug],
  248. [Bonus] AS [Bonus],
  249. [int. Kosten] AS [int. Kosten],
  250. --[Current Branch Book No] AS [Current Branch Book No],
  251. --[Current Book No] AS [Current Book No],
  252. --[Summe EK-FZG] AS [Summe EK-FZG],
  253. [Fabrikat] AS [Fabrikat],
  254. --[Buchnummer gleich_ja_nein] AS [Buchnummer gleich_ja_nein],
  255. --[Menge1] AS [Menge1],
  256. --[Menge2] AS [Menge2],
  257. --[Menge3] AS [Menge3],
  258. --[Menge4] AS [Menge4],
  259. --[VIN + PostingDate] AS [VIN + PostingDate],
  260. --[Summe Menge4] AS [Summe Menge4],
  261. --[Menge_2_test] AS [Menge_2_test],
  262. --[Menge3_test] AS [Menge3_test],
  263. --[Menge4_test] AS [Menge4_test],
  264. --[Fahrzeugart_Schmidt] AS [Fahrzeugart_Schmidt],
  265. --[Salespers Purch Code_VLE] AS [Salespers Purch Code_VLE],
  266. --[Code_für_VEH_Ledger_Entry] AS [Code_für_VEH_Ledger_Entry],
  267. --[Name_für_VEH_Ledger_Entry] AS [Name_für_VEH_Ledger_Entry],
  268. [Verkäufer] AS [Verkäufer],
  269. --[FZG_Liste_1_falsch] AS [FZG_Liste_1_falsch],
  270. --[FZG_Liste_0_ori] AS [FZG_Liste_0_ori],
  271. --[FZG_Liste_1] AS [FZG_Liste_1],
  272. --[FZG_Liste_0] AS [FZG_Liste_0],
  273. [Beleg] AS [Beleg],
  274. --[Standort_FIBU] AS [Standort_FIBU],
  275. --[Fahrzeugart_neu] AS [Fahrzeugart_neu],
  276. [Standort] AS [Standort],
  277. --[Summe_Betrag] AS [Summe_Betrag],
  278. --[Vat Bus Posting Group_Kunde] AS [Vat Bus Posting Group_Kunde],
  279. --[FZG_Liste_5_ori] AS [FZG_Liste_5_ori],
  280. --[Customer Group Code] AS [Customer Group Code],
  281. --[FZG_Liste_5] AS [FZG_Liste_5],
  282. --[FZG_Liste_6] AS [FZG_Liste_6],
  283. --[FZG_Liste_7] AS [FZG_Liste_7],
  284. [FZG_Detail] AS [FZG_Detail],
  285. [Menge_final] AS [Menge_final],
  286. [No] + ' - ' + [Name] AS [Konto],
  287. --[No_Item] AS [No_Item],
  288. --[Description_Item] AS [Description_Item],
  289. --[Vehicle Type Code_Item] AS [Vehicle Type Code_Item]
  290. FROM [export_csv].[NW_GW_VK_TIM_Grosskd]
  291. GO