davidjmorin

Untitled

Jun 1st, 2020
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.84 KB | None | 0 0
  1. $sqlAdmin = "SELECT
  2. *,y.all_notes
  3. FROM (
  4. SELECT Tracking_,
  5. pa.Purchased_Receivable,
  6. MID(pa.Purchased_Receivable,2,15),
  7. a.Selling_Price,
  8. 'Activations' as `table`,
  9. pa.Customer_Name,
  10. a.Sold_By,
  11. a.Invoice_,
  12. a.Invoiced_By,
  13. a.Sold_On,
  14. a.ID
  15. FROM dp_expected as a
  16. LEFT JOIN disc_Activations as pa
  17. ON a.Tracking_ = pa.Mobile_ID
  18. WHERE MID(a.Selling_Price ,2,15) != MID(pa.Purchased_Receivable,2,15)
  19. AND pa.Purchased_Receivable IS NOT NULL
  20. AND pa.Purchased_Receivable != ''
  21. #AND a.Selling_Price LIKE '%-%'
  22. AND STR_TO_DATE(a.Sold_On, '%b %e, %Y %l:%i %p') BETWEEN '".$mindate."' AND '".$maxdate."'
  23. GROUP BY a.Tracking_
  24.  
  25. UNION ALL
  26.  
  27. SELECT Tracking_,
  28. pa.Purchased_Receivable,
  29. MID(pa.Purchased_Receivable,2,15),
  30. a.Selling_Price,
  31. 'Upgrades' as `table`,
  32. pa.Customer_Name,
  33. a.Sold_By,
  34. a.Invoice_,
  35. a.Invoiced_By,
  36. a.Sold_On,
  37. a.ID
  38.  
  39. FROM dp_expected as a
  40. LEFT JOIN disc_Upgrades as pa
  41. ON a.Tracking_ = pa.Mobile_ID
  42. WHERE MID(a.Selling_Price ,2,15) != MID(pa.Purchased_Receivable,2,15)
  43. AND pa.Purchased_Receivable IS NOT NULL
  44. AND pa.Purchased_Receivable != ''
  45. #AND a.Selling_Price LIKE '%-%'
  46. AND STR_TO_DATE(a.Sold_On, '%b %e, %Y %l:%i %p') BETWEEN '".$mindate."' AND '".$maxdate."'
  47. GROUP BY a.Tracking_
  48.  
  49. ) as x
  50. LEFT JOIN (
  51. SELECT n.note_id,
  52. GROUP_CONCAT(n.note, ' - (Checked By: ', n.user, ')' ORDER BY n.note_id separator '<br>') as all_notes
  53. FROM dpe_notes n
  54. GROUP BY n.note_id
  55. ) AS y
  56. ON y.note_id = x.ID
  57. ";
Advertisement
Add Comment
Please, Sign In to add comment