Guest User

Untitled

a guest
Dec 11th, 2018
250
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. SELECT
  2. ROW_NUMBER() OVER(ORDER BY c.FullName ASC) AS No#,
  3. a.AcctBranchName,
  4. c.FullName,
  5. c.BirthDate,
  6. c.Age,
  7. a.StartDate as 'Account Start Date',
  8. c.CustStartDate as 'Customer Start Date',
  9. c.CustomerNum,
  10. a.Currency,
  11. a.AccountNum,
  12. a.ProductType as 'Product Name',
  13. a.Balance as 'Balance KHR',
  14. a.BalanceUSDEquiv as 'Balance USA',
  15. aa.ClosedDate,
  16.  
  17. CASE
  18. WHEN (a.BalanceUSDEquiv*3 >= 200000) then '200,000'
  19. ELSE a.BalanceUSDEquiv*3 end as 'Sum Insure in USD',
  20. CASE
  21. WHEN (a.BalanceUSDEquiv*3 > 200000) then 200000*(0.1/100)/12
  22. ELSE a.BalanceUSDEquiv*3*(0.1/100)/12 end as 'Premium to be paid'
  23.  
  24. FROM
  25. v_Account AS a
  26. LEFT join v_Customer AS c
  27. ON c.CustomerID = a.CustomerID AND c.Businessdate = a.Businessdate
  28.  
  29. WHERE
  30. a.AccountNum IN (
  31. SELECT aa.AccountNum FROM v_Account AS aa WHERE
  32. aa.Category = 'Deposit' AND aa.ProductCode IN ('6003', '6253')
  33. AND aa.Businessdate='2018-12-06' AND aa.ClosedDate is not NULL
  34. )
  35. AND a.Category = 'Deposit'
  36. AND a.ProductCode IN ('6003', '6253')
  37. AND c.Businessdate='2018-12-05'
Add Comment
Please, Sign In to add comment