NadezhdaGeorgieva

09. Find all information of stores 18 Oct 2020

Jun 17th, 2021
1,294
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. SELECT
  2.     REVERSE(s.name) AS reverse_name,
  3.     CONCAT(UPPER(t.name), '-', a.name) AS full_address,
  4.     COUNT(e.id) AS employees_count
  5. FROM
  6.     stores AS s
  7.         LEFT JOIN
  8.     addresses AS a
  9.     ON s.address_id = a.id
  10.         LEFT JOIN
  11.     towns AS t
  12.     ON a.town_id = t.id
  13.         LEFT JOIN
  14.     employees AS e
  15.     ON s.id = e.store_id
  16. GROUP BY s.id
  17. HAVING employees_count >= 1
  18. ORDER BY full_address;
RAW Paste Data