Advertisement
Guest User

Untitled

a guest
May 4th, 2016
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. ) as view1
  2. where currencyAbbr!=''
  3. and ForexAmount!=0
  4. and BS='B'
  5. order by currencyabbr) as firstbuy
  6. union all
  7.  
  8. select * from
  9. (
  10. select distinct CONCAT(date(tr.dateandtime),' ',time(tr.dateandtime)) as transdatetime,
  11. CONCAT(date(tr.dateandtime),':',br.branchcode,':',tr.employeeid,':', tr.sequencenumber) as transactionnumber,
  12. tr.sequencenumber as SN, CONCAT(emp.employeeid,'-',emp.employeename) as TRL, br.BranchCode as BR,
  13. tr.TerminalID as TRM, fx.MidPointRate as WHRate, fx.PreviousDayMidPointRate as PRRate, CASE WHEN tr.currencycode=0
  14. then ' ' else currenc_abb(tr.currencycode) END as currencyabbr,
  15. CASE When tr.transactioncodeid in (2,3) then 'CASH'
  16. when tr.transactioncodeid=22005 then 'DRAFT'
  17. when tr.transactioncodeid=4 then 'ACCOUNT'
  18. when tr.transactioncodeid=22003 then 'WIRE' END as TYPE ,
  19. fx.operations as BS, CASE WHEN tr.forexamount=0 then ' '
  20. else FORMAT(tr.forexamount,2) END as ForexAmount, fx.ActualRate as TransRate,
  21. FORMAT(tr.amount,2) as Amount
  22. from `tbltransaction` tr
  23. Left JOIN `tblforextransaction` fx ON tr.dateandtime=fx.dateandtime
  24. INNER JOIN `tblbranch` br ON br.branchid=tr.branchid
  25. left join `tblemployee` emp on tr.employeeid=emp.employeeid
  26. where tr.branchid=11
  27. and date(tr.dateandtime)='2016-04-29'
  28.  
  29. ) as view2
  30. where currencyAbbr!=''
  31. and ForexAmount!=0
  32. and BS='B'
  33. order by currencyabbr
  34. ) as blankline
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement