Skip to content

VishalSingh-Module-3#81

Open
vishalsingh456 wants to merge 3 commits intohotwax:mainfrom
vishalsingh456:vishalSingh-Module3
Open

VishalSingh-Module-3#81
vishalsingh456 wants to merge 3 commits intohotwax:mainfrom
vishalsingh456:vishalSingh-Module3

Conversation

@vishalsingh456
Copy link

I learned SQL in depth

-Learned basics of MYSQL/SQL
-Completed Module-3 all questions
-Learned in depth about SQL joins.




mysql> select * from customer where RATING=100;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SQL keywords should be uppercase.


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;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wrong output

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;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SQL indentation required in all queries.

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;
Copy link

@sadhanaa21 sadhanaa21 May 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 |
+------+---------+-----------+------+------------+------------+

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wrong dates in output corresponding to order amount

| Motika | 1990-03-10 | 3002 | 1900.1 | Rome |
| Rifkin | 1990-03-10 | 3006 | 1098.16 | Sanjose |
+---------+------------+------+---------+---------+
5 rows in set (0.00 sec)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wrong output.
Also rework on query number 34, 71, 97, 107 as they are giving wrong outputs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants