Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- 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”.
- SELECT CNAME, CITIES, CONCAT(RATING, ' HIGHER RATING') AS RATING FROM CUSTOMER WHERE RATING >= 200 UNION
- SELECT CNAME, CITIES, CONCAT(RATING, ' LOWER RATING') AS RATING FROM CUSTOMER WHERE RATING < 200;
- -- 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.
- (SELECT CNUM ,COUNT(*)
- FROM ORDERS
- GROUP BY CNUM
- HAVING COUNT(*) > 1 ORDER BY CNUM)
- UNION
- (SELECT SNUM ,COUNT(*)
- FROM ORDERS
- GROUP BY SNUM
- HAVING COUNT(*) > 1 ORDER BY SNUM);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement