Advertisement
ghx8

cek_mx_rk_sbg

Mar 24th, 2018
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
T-SQL 1.96 KB | None | 0 0
  1.  
  2. select src, count(*) from mx0
  3. where src like '%ac8258%'
  4. group by src
  5.  
  6. select * from mx0 where amt1=14658593
  7.  
  8. select * from mx0 where amt1 != amt2
  9.  
  10. ---- cek str sbg ----
  11. -- bikin temp table --
  12. drop table #mx
  13. select date,acct2 acct,amt2/1000 amount into #mx
  14. from mx0 where src like '%ac8258_201801'
  15. and acct2='ac8258'
  16. select * from #mx
  17.  
  18. -- cek match join --
  19. select s.*, b.date,b.payee from
  20. (select * from sbg.rk where acno like '%8258') b join
  21. (select * from #mx) s on b.amount=s.amount
  22.  
  23. -- self-all = left join --
  24. select s.*, b.date,b.payee from
  25. (select * from #mx) s left join
  26. (select * from sbg.rk where acno like '%8258' and ctg is null) b
  27.  on s.amount=b.amount
  28.  
  29.  -- update RK if match with mx --
  30. update sbg.rk set cmd=501, ctg='str',xctg='tunai',ref=s.date
  31. from sbg.rk join
  32. (select * from sbg.rk where acno like '%8258' and ctg is null) b
  33. on rk.id=b.id join (select * from #mx) s
  34. on round(b.amount,0,1)=round(s.amount,0,1)
  35. and datediff(dd,s.date,b.date)<7
  36.  
  37. -- cek self not bank --
  38. select s.*, b.date,b.payee from
  39. (select * from #mx) s left join
  40. (select * from sbg.rk where acno like '%8258') b
  41.  on s.amount=b.amount and s.date=b.ref
  42. order by s.date
  43.  
  44. select * from sbg.rk where acno like '%8258'
  45. and date between '20180101' and '20180201'
  46. and amount > 0 and ctg is null
  47.  
  48. select * from sbg.rk where acno like '%8258'
  49. and year(date)=2018 and month(date)=1
  50.  
  51. select type, sum(amount), count(*) from rkbca where acno like '%8258'
  52. and year(date)=2018 and month(date)=1
  53. group by type
  54.  
  55.  
  56.  
  57.  select cmd, count(*) from sbg.rk
  58.  where acno like '%8258'
  59.  and ctg='str'
  60.  group by cmd
  61.  
  62.  update  sbg.rk set ctg=null, xctg=null, cmd=null
  63.  where cmd in (110,113,121)
  64.  
  65.  
  66. select s.amount-b.amount, s.*, b.date,b.payee, datediff(dd,s.date,b.date) from
  67. (select * from sbg.rk where acno like '%8258' and ctg is null) b join
  68. (select * from #mx) s on round(b.amount,0,1)=round(s.amount,0,1)
  69. and datediff(dd,s.date,b.date)<7
  70.  
  71. select round(123.567,0,1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement