Advertisement
Guest User

Untitled

a guest
Sep 18th, 2019
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQL 1.54 KB | None | 0 0
  1. SELECT job.id, DISTINCT company_name, city, job.title, hourly_rate_amount, created_at,
  2. COUNT(work_intent.id), number_of_contractors,
  3. (COUNT(work_intent.id)/number_of_contractors) AS aantal_reacties,
  4. (3959 * acos(cos(radians(51.54348510000000)) * cos( radians(address.latitude))
  5. * cos(radians(longitude) - radians(4.94570490000000)) + sin(radians(51.54348510000000)) * sin(radians(latitude)))) AS afstand_klus
  6. FROM job
  7. INNER JOIN client ON job.client_id = client.id
  8. INNER JOIN address ON job.address_id = address.id
  9. LEFT JOIN work_intent ON job.id = work_intent.job_id
  10. INNER JOIN job_title ON job.job_title_id = job_title.id
  11. WHERE job_title.id = ANY
  12. (SELECT job_title.id FROM job_title WHERE job.job_title_id = '28'
  13. OR job.job_title_id = '30'
  14. OR job.job_title_id = '31'
  15. OR job.job_title_id = '32'
  16. OR job.job_title_id = '35'
  17. OR job.job_title_id = '38'
  18. OR job.job_title_id = '39'
  19. OR job.job_title_id = '40'
  20. OR job.job_title_id = '41'
  21. OR job.job_title_id = '42'
  22. OR job.job_title_id = '46'
  23. OR job.job_title_id = '49'
  24. OR job.job_title_id = '50'
  25. OR job.job_title_id = '52'
  26. OR job.job_title_id = '53'
  27. OR job.job_title_id = '55'
  28. OR job.job_title_id = '59'
  29. OR job.job_title_id = '60'
  30. OR job.job_title_id = '61'
  31. OR job.job_title_id = '62'
  32. OR job.job_title_id = '66'
  33. OR job.job_title_id = '67'
  34. OR job.job_title_id = '68'
  35. OR job.job_title_id = '70'
  36. )
  37. AND job.STATUS = 'open'
  38. AND CONVERT(job.starts_at, DATE) = '2019-09-25'
  39. AND hourly_rate_amount > 1300
  40. GROUP BY job.id
  41. HAVING afstand_klus < 200
  42. ORDER BY aantal_reacties, afstand_klus
  43. LIMIT 100
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement