SHARE
TWEET

Untitled

a guest Jan 17th, 2019 57 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. SELECT
  2. r.id AS 'reservationId',
  3. r.project_id AS projectId,
  4. d.id AS 'departureId',
  5. t.code AS 'trip',
  6. t_t.one_letter_code,
  7. t.locale_id AS 'localeId',
  8. d.departure_status_id AS 'status',
  9. r.reservation_confirmation_date AS 'dateConfirm',
  10. d.start_date AS 'dateDeparture',
  11. (SELECT bank_slip_date FROM payment p WHERE p.invoice_number_id = r.invoice_number_id order by bank_slip_date asc limit 1) AS down_payment_date,
  12. (SELECT COUNT(*) FROM client_reservation_relation crr WHERE crr. reservation_id = r.id and ((crr.is_storned = 0 AND crr.is_cancelled != 1) OR crr.is_storned = 1)) AS PAX,
  13. t.default_max_no_of_pax AS 'MAX',
  14. t.default_min_no_of_pax AS 'MIN',
  15. r.cached_estimated_margin AS 'marginEstimated',
  16. r.cached_estimated_margin_date AS 'dateDPayment',
  17. r.cached_real_margin AS 'marginReal',
  18. r.old_id AS 'reservationIdOld'
  19.  
  20.  
  21.  
  22.  
  23. FROM trip t
  24.  
  25. LEFT JOIN departure d ON d.trip_id = t.id
  26. LEFT JOIN trip_type tt ON tt.id = t.trip_type_id
  27. LEFT JOIN departure_order do ON do.departure_id = d.id
  28. LEFT JOIN client_reservation_relation crr ON crr.id = do.client_reservation_relation_id
  29. LEFT JOIN reservation r ON r.id = crr.reservation_id
  30. LEFT JOIN go_user gu ON gu.id = t.current_contact_person_go_user_id
  31. LEFT JOIN trip_type t_t ON t_t.id = t.trip_type_id
  32.  
  33. WHERE r.created_at > '2014-01-01' AND
  34. t.locale_id IN ('de_DE', 'fr_FR') AND
  35. tt.trip_meta_type_id IN (1) AND
  36. d.departure_status_id IN (2, 3, 4, 5)
  37.  
  38. GROUP BY r.id, d.id, t.code, t.locale_id
  39. ORDER BY d.id DESC
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top