Advertisement
Pandaaaa906

Untitled

Jun 24th, 2022
1,297
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MySQL 1.11 KB | None | 0 0
  1. SELECT
  2. bv_report_index.report_no AS report_no,
  3. tmp.material_article_no,
  4. coalesce(bv_report_index.report_batch_no, bv_report_index.u8_batch_no) AS batch_no,
  5. bv_report_index.path AS path,
  6. bv_report_index.purity AS purity
  7. FROM bv_report_index
  8. INNER JOIN (
  9.     SELECT bv_report_index.product_id AS product_id,
  10.         bv_product.material_article_no,
  11.     coalesce(bv_report_index.report_batch_no, bv_report_index.u8_batch_no) AS cert_batch_no,
  12.     max(bv_report_index.add_time) AS add_time
  13.     FROM bv_report_index
  14.     LEFT OUTER JOIN bv_product
  15.     ON bv_product.id = bv_report_index.product_id
  16. WHERE (bv_product.material_article_no LIKE concat('%%', 'C4X-1108%'))
  17. -- and coalesce(bv_report_index.report_batch_no, bv_report_index.u8_batch_no) = '0602-RD-0006'
  18. AND bv_report_index.approve_time != 0
  19. AND bv_report_index.ref_report_no = 0
  20. GROUP BY coalesce(bv_report_index.report_batch_no, bv_report_index.u8_batch_no)
  21. ) AS tmp
  22. ON tmp.cert_batch_no = coalesce(bv_report_index.report_batch_no, bv_report_index.u8_batch_no)
  23. AND tmp.add_time = bv_report_index.add_time
  24. AND tmp.product_id = bv_report_index.product_id
  25.  
  26.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement