Open
Conversation
sadhanaa21
reviewed
May 17, 2023
|
|
||
|
|
||
|
|
||
| mysql> select * from customer where RATING=100; |
|
|
||
| 3) Find the largest order taken by each salesperson on each date. | ||
|
|
||
| mysql> select s.SNAME, max(o.AMT) as orderAmount, ODATE from orders as o,salespeople as s where s.SNUM=o.SNUM group by o.SNUM,o.ODATE; |
| 8) Count the orders of each of the salespeople and output the results in descending order. | ||
|
|
||
|
|
||
| mysql> SELECT s.snum, s.sname, COALESCE(COUNT(o.onum), 0) as order_count FROM salespeople as s LEFT JOIN orders as o ON s.snum = o.snum GROUP BY s.snum, s.sname ORDER BY order_count DESC; |
There was a problem hiding this comment.
SQL indentation required in all queries.
Module3/SQL_Assignment.txt
Outdated
| 21) List all the largest orders for October 3, for each salesperson. | ||
|
|
||
|
|
||
| mysql> SELECT ONUM,ODATE,MAX(o.AMT) as AMOUNT from orders as o inner join salespeople as s on o.SNUM=s.SNUM where o.ODATE like '%-03-10' group by s.SNUM; |
There was a problem hiding this comment.
Left join should be used. Try to use appropriate joins in all queries as well.
|
|
||
|
|
||
| 65) Write a query using ANY or ALL that will find all salespeople who have no customers located in their city. | ||
|
|
There was a problem hiding this comment.
Question clearly says you have to use ANY or ALL here.
| 7 rows in set (0.00 sec) | ||
|
|
||
|
|
||
| 47) Write a query that lists each order number followed by the name of the customer who made that order. |
There was a problem hiding this comment.
Wrong data entered here. Correct it in all affected queries.
| | 1001 | Peel | London | 12 | 1990-03-10 | 9891.88 | | ||
| | 1002 | Serres | Sanjose | 13 | 1990-03-10 | 5160.45 | | ||
| | 1003 | AxelRod | New York | 10 | 1990-04-10 | 1713.23 | | ||
| +------+---------+-----------+------+------------+------------+ |
There was a problem hiding this comment.
Wrong dates in output corresponding to order amount
Module3/SQL_Assignment.txt
Outdated
| | Motika | 1990-03-10 | 3002 | 1900.1 | Rome | | ||
| | Rifkin | 1990-03-10 | 3006 | 1098.16 | Sanjose | | ||
| +---------+------------+------+---------+---------+ | ||
| 5 rows in set (0.00 sec) |
There was a problem hiding this comment.
Wrong output.
Also rework on query number 34, 71, 97, 107 as they are giving wrong outputs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I learned SQL in depth
-Learned basics of MYSQL/SQL
-Completed Module-3 all questions
-Learned in depth about SQL joins.