Advertisement
Guest User

Untitled

a guest
Sep 2nd, 2015
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.68 KB | None | 0 0
  1. (SELECT
  2. tsl.rtl_loc_id store_id,
  3. loc_rtl_loc.store_name store_name,
  4. hrs_employee.login_id Emp_id,
  5. COALESCE(crm_party.first_name,' ')+' '+ COALESCE(crm_party.middle_name,' ')+' '+COALESCE(crm_party.last_name,' ') Emp_name,
  6. convert(datetime, tsl.business_date, 103) bus_date,
  7. tsl.business_date bus_time
  8. FROM trn_trans tsl -- transaction header
  9. --join transaction details
  10. INNER JOIN trl_sale_lineitm tr_det
  11. ON tr_det.organization_id=tsl.organization_id
  12. AND tr_det.rtl_loc_id=tsl.rtl_loc_id
  13. AND tr_det.wkstn_id=tsl.wkstn_id
  14. AND tr_det.trans_seq=tsl.trans_seq
  15. --join for price override extraction
  16. INNER JOIN trl_rtl_price_mod prc_chg
  17. ON prc_chg.organization_id=tsl.organization_id
  18. AND tr_det.rtl_loc_id=prc_chg.rtl_loc_id
  19. AND tr_det.wkstn_id=prc_chg.wkstn_id
  20. AND tr_det.trans_seq=prc_chg.trans_seq
  21. AND tr_det.rtrans_lineitm_seq=prc_chg.rtrans_lineitm_seq
  22. AND rtl_price_mod_reascode='PRICE_OVERRIDE'
  23. AND void_flag=0
  24. --join for login extraction
  25. INNER JOIN hrs_employee
  26. ON hrs_employee.organization_id=tsl.organization_id
  27. AND hrs_employee.party_id=tsl.create_user_id
  28. --join for employee name extraction
  29. LEFT JOIN crm_party
  30. ON crm_party.organization_id=tsl.organization_id
  31. AND crm_party.party_id=hrs_employee.party_id
  32. LEFT JOIN loc_rtl_loc
  33. ON loc_rtl_loc.organization_id=tsl.organization_id
  34. AND loc_rtl_loc.rtl_loc_id=tsl.rtl_loc_id
  35. WHERE
  36. tsl.trans_typcode = 'RETAIL_SALE'
  37. AND tsl.trans_statcode='COMPLETE'
  38. -- tsl.rtl_loc_id = (COALESCE(null,tsl.rtl_loc_id))
  39. -- AND tsl.return_flag = '0'
  40. -- AND tsl.QUANTITY <> 0
  41. -- AND tsl.business_date>$P{Date_from}
  42. -- AND tsl.business_date< $P{Date_to}
  43. )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement