Guest User

Untitled

a guest
Dec 14th, 2017
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. SELECT
  2. communications.creation_date as message_date,
  3. message as message_text,
  4. employees.first_name || ' ' || coalesce(employees.middle_name,'') || ' ' || employees.last_name as message_by
  5. FROM app.communications
  6. INNER JOIN app.employees ON communications.message_from = employees.emp_id
  7. WHERE send_as_sms = TRUE AND com_id = (SELECT MAX(com_id) FROM app.communications)
  8.  
  9. SELECT
  10. cs.com_id,
  11. cs.first_name ||' ' || cs.last_name AS recipient_name,
  12. cs.sim_number AS phone_number
  13. FROM app.communication_sms cs
  14. WHERE cs.com_id = (SELECT MAX(cs2.com_id) FROM app.communication_sms cs2)
  15. ORDER BY first_name ASC
Add Comment
Please, Sign In to add comment