Advertisement
Guest User

Untitled

a guest
Apr 1st, 2015
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. -- Create a union of two queries that shows the names, cities, and ratings of all customers. Those with rating of 200 or greater will also have the words “High Rating”, while the others will have the words “Low Rating”.
  2.  
  3. SELECT CNAME, CITIES, CONCAT(RATING, ' HIGHER RATING') AS RATING FROM CUSTOMER WHERE RATING >= 200 UNION
  4. SELECT CNAME, CITIES, CONCAT(RATING, ' LOWER RATING') AS RATING FROM CUSTOMER WHERE RATING < 200;
  5.  
  6.  
  7. -- Write a command that produces the name and number of each salesperson and each customer with more than one current order. Put the results in alphabetical order.
  8.  
  9. (SELECT CNUM ,COUNT(*)
  10. FROM ORDERS
  11. GROUP BY CNUM
  12. HAVING COUNT(*) > 1 ORDER BY CNUM)
  13. UNION
  14. (SELECT SNUM ,COUNT(*)
  15. FROM ORDERS
  16. GROUP BY SNUM
  17. HAVING COUNT(*) > 1 ORDER BY SNUM);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement