Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SELECT
- ROW_NUMBER() OVER(ORDER BY c.FullName ASC) AS No#,
- a.AcctBranchName,
- c.FullName,
- c.BirthDate,
- c.Age,
- a.StartDate as 'Account Start Date',
- c.CustStartDate as 'Customer Start Date',
- c.CustomerNum,
- a.Currency,
- a.AccountNum,
- a.ProductType as 'Product Name',
- a.Balance as 'Balance KHR',
- a.BalanceUSDEquiv as 'Balance USA',
- aa.ClosedDate,
- CASE
- WHEN (a.BalanceUSDEquiv*3 >= 200000) then '200,000'
- ELSE a.BalanceUSDEquiv*3 end as 'Sum Insure in USD',
- CASE
- WHEN (a.BalanceUSDEquiv*3 > 200000) then 200000*(0.1/100)/12
- ELSE a.BalanceUSDEquiv*3*(0.1/100)/12 end as 'Premium to be paid'
- FROM
- v_Account AS a
- LEFT join v_Customer AS c
- ON c.CustomerID = a.CustomerID AND c.Businessdate = a.Businessdate
- WHERE
- a.AccountNum IN (
- SELECT aa.AccountNum FROM v_Account AS aa WHERE
- aa.Category = 'Deposit' AND aa.ProductCode IN ('6003', '6253')
- AND aa.Businessdate='2018-12-06' AND aa.ClosedDate is not NULL
- )
- AND a.Category = 'Deposit'
- AND a.ProductCode IN ('6003', '6253')
- AND c.Businessdate='2018-12-05'
Add Comment
Please, Sign In to add comment