[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

SQL Question_New

Posted on 2013-01-13
2
Medium Priority
?
341 Views
Last Modified: 2013-01-13
INVENTORY.partid, INVENTORY.description, (INVENTORY.reorderpnt - INVENTORY.stockqty)
 

Display the part id and description for all parts where the stock quantity is less than the reorder point.   I have this one working:

SELECT PartID
     , Description
FROM INVENTORY
WHERE Stockqty <= Reorderpnt;

How can I modify  the query above to get the below :

For each part where this is true also display the amount that the stock quantity is below the reorder point. Display the parts in descending order of the computed difference.
0
Comment
Question by:ocdc
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 23

Accepted Solution

by:
Steve Wales earned 2000 total points
ID: 38773208
SELECT PartID, Description, abs(stockqty - reorderpnt) as understockamt
FROM INVENTORY
WHERE Stockqty <= Reorderpnt
order by understockamt desc; 

Open in new window


As an aside...

Not being judgemental or anything, but I get the feeling from the questions you're asking that you're either following some form of teach yourself SQL book or this is a class assignment.

While I don't mind helping you with the solutions you need (that is what the site is for, after all), if it is a class related assignment, it is imperative that you fully understand why these things work the way they do - there's no EE about when it's time to be examined on what you know :)

The help available on SQL Syntax in Books Online and on the internet in general is exhaustive.

Make sure you have a good understanding of the concepts by doing a lot of reading.

Like I said, not trying to pass judgement, want to make sure you are getting everything out of whatever it is you're doing.  Understanding the results is just as important as the results themselves.
0
 

Author Comment

by:ocdc
ID: 38773256
Thanks. Actually, I had done it myself  and just double checking.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Recently, when I was asked to create a new SQL 2005 cluster, Microsoft released a new service pack for MS SQL 2005 what is Service Pack 3. When I finished the installation of MS SQL 2005 I found myself troubled why the installation of SP3 failed …
I am showing a way to read/import the excel data in table using SQL server 2005... Suppose there is an Excel file "Book1" at location "C:\temp" with column "First Name" and "Last Name". Now to import this Excel data into the table, we will use…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question