Advertisement
Guest User

Untitled

a guest
Sep 17th, 2019
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. SELECT DISTINCT
  2. a.tyear,
  3. a.tperiod,
  4. b.country_group,
  5. b.tipe_product
  6. FROM
  7. (SELECT DISTINCT YEAR
  8. ( a.Bill_date ) as 'tyear',
  9. MONTH ( a.bill_date ) as 'tperiod'
  10. FROM
  11. billing_document_header_data as a
  12. union
  13. select distinct ts.`year`, ts.period from target_sales as ts
  14. where CONCAT(ts.`Year`,ts.period) not in
  15. (
  16. SELECT DISTINCT
  17. CONCAT(YEAR( bl.Bill_date ),MONTH ( bl.bill_date )) as 'typ'
  18. FROM
  19. billing_document_header_data as bl))
  20. AS a
  21. join
  22. (select DISTINCT c.country_group, d.tipe_product from customer_mapping as c
  23. left join (select distinct Country_Group_Target_Export, tipe_product
  24. from table_target_area) as d
  25. on c.country_group=d.Country_Group_Target_Export) as b;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement