question

RAJ 1 avatar image
RAJ 1 asked

SQL Query - delete all orders from Employee with minimum sales

EMPLOYEE(ENO,ENMAME,) ORDERS(ONO,ENO) PARTS(PNO,PRICE) Please tell me query that will delete all the orders from Employee with minimum sales
t-sqlhomework
3 comments
10 |1200 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Caps Lock is a key to the left of your keyboard, that lets you write text with normal casing. Although the letters on the keyboard fascia are upper case, it is in fact possible, and desirable, to write text using normal casing - especially on the Internet.
2 Likes 2 ·
The good news is that SSMS has **Ctrl**+**A** to select text and then press **Shift**+**Ctrl**+**L** to transform the text to lower case :) On the unrelated note, I have met someone who always writes everything in **ALL CAPS**, including ***email messages***. The good news is that I don't have to work with this dude, **ALL CAPS** would be way too annoying for me to tolerate.
0 Likes 0 ·

1 Answer

· Write an Answer
Grant Fritchey avatar image
Grant Fritchey answered
You need to join orders to parts and there's no method based on the tables you're showing. But, the trick is, build the SELECT statement that will get you the data you want first: SELECT TOP 1 SUM(PRICE) as TotalSales ,ENO FROM Orders 0 JOIN Parts p ON [some key not defined] GROUP BY ENO ORDER BY TotalSales DESC When you've got the data coming out correctly, you just need to incorporate the same query into a DELETE statement.
10 |1200 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.