Advertisement
Guest User

Untitled

a guest
Jun 20th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.61 KB | None | 0 0
  1. SELECT Seller_FullNameStreetCityState = CASE WHEN NULLIF(L.DbaName, '') IS NOT NULL THEN L.DbaName + ', ' + L.LotAddress + ', ' + L.LotCity + ', ' + L.LotState + ', ' + L.LotZip ELSE D.CompanyName + ', ' + D.CompanyAddress + ', ' + D.CompanyCity + ', ' + D.CompanyState + ', ' + D.CompanyZip END,
  2. Seller_FullNameStreetCityState1 = CASE WHEN NULLIF(L.DbaName, '') IS NOT NULL THEN L.DbaName ELSE D.CompanyName END,
  3. Seller_FullNameStreetCityState2 = CASE WHEN NULLIF(L.DbaName, '') IS NOT NULL THEN L.LotAddress + ', ' ELSE D.CompanyAddress + ', ' END,
  4. Seller_FullNameStreetCityState3 = CASE WHEN NULLIF(L.DbaName, '') IS NOT NULL THEN L.LotCity + ', ' + L.LotState + ', ' + L.LotZip ELSE D.CompanyCity + ', ' + D.CompanyState + ', ' + D.CompanyZip END,
  5. Form_Date = CONVERT(CHAR(10), GetDate(), 101),
  6. Vehicle_Year = C.year,
  7. Vehicle_Make = C.make,
  8. Vehicle_Model = C.model,
  9. Vehicle_Other_Text_MULTIPART_1 = C.style,
  10. Vehicle_IdentificationNumber = C.vin,
  11. Insurance_Agent_FullNameAddressyDayPhone = NULLIF(A.InsuranceAgent, '') + ', ' + A.InsuranceAddress + ', ' + A.InsurancePhone,
  12. A.InsurancePolicy AS Insurance_PolicyNumber,
  13. A.InsuranceColl AS Insurance_Vehicle_Collision_Deductible_Amount,
  14. A.InsuranceComp AS Insurance_Vehicle_Comprehensive_Deductible_Amount,
  15. A.InsuranceDateFrom AS Form_EffectiveFrom_Date,
  16. A.InsuranceDate AS Form_EffectiveTo_Date,
  17. AllBorrowers_FullNameStreetCityZip = RTRIM(B.Firstname) + ' ' + RTRIM(B.Lastname) + ', ' + B.Address + ', ' + B.City + ', ' + B.Zip,
  18. AllBorrowers_FullNameStreetCityZip1 = RTRIM(B.Firstname) + ' ' + RTRIM(B.Lastname),
  19. AllBorrowers_FullNameStreetCityZip2 = B.Address + ', ',
  20. AllBorrowers_FullNameStreetCityZip3 = B.City + ', ' + B.STATE + ', ' + B.Zip,
  21. Agreement_FirstSigner_FullName = RTRIM(B.Firstname) + ' ' + RTRIM(B.Lastname),
  22. Agreement_SecondSigner_FullName = RTRIM(B2.Firstname) + ' ' + RTRIM(B2.Lastname),
  23. Payee_FullNameStreetCityStateZip = A.financecompany + ', ' + V.VendorAddress + ', ' + V.VendorCity + ', ' + V.VendorState + ', ' + V.VendorZip,
  24. LienholderInfo_Name = V.VendorName,
  25. LienholderInfo_Address = V.VendorAddress,
  26. LienholderInfo_City = V.VendorCity,
  27. LienholderInfo_State = V.VendorState,
  28. LienholderInfo_Zip = V.VendorZip
  29. FROM DealsTable A
  30. INNER JOIN customertable B ON B.customercode = A.buyercode
  31. INNER JOIN inventorytable C ON C.StockNumber = A.StockNumber
  32. INNER JOIN LotsTable L ON A.LotName = L.LotName
  33. LEFT JOIN CustomerTable B2 ON B2.CustomerCode = A.CoBuyerCode
  34. LEFT JOIN VendorListTable V ON V.VendorName = A.FinanceCompany
  35. LEFT JOIN DMSData..CompanyTable D ON D.CompanyCode = '<CompanyCode>'
  36. WHERE A.AccountNumber = '<AccountNumber>'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement