SHARE
TWEET

Untitled

a guest May 23rd, 2019 89 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. WITH amount_earned_table AS
  2. (SELECT amount_earned
  3. FROM daily_sales
  4. INNER JOIN salesman
  5. ON daily_sales.salesman_id = salesman.id
  6. INNER JOIN city
  7. ON salesman.city_id = city.id
  8. GROUP BY city.name),
  9.  
  10. avgDailyAmt AS
  11. (SELECT AVG(amount_earned)
  12. FROM amount_earned_table)
  13.  
  14. SELECT city.id, city.name
  15. FROM city
  16. INNER JOIN avgDailyAmt
  17. ON
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