Solved

SQL Question_New

Posted on 2013-01-13
2
323 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
2 Comments
 
LVL 22

Accepted Solution

by:
Steve Wales earned 500 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

Zoho SalesIQ

Hassle-free live chat software re-imagined for business growth. 2 users, always free.

Question has a verified solution.

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

Suggested Solutions

by Mark Wills Attending one of Rob Farley's seminars the other day, I heard the phrase "The Accidental DBA" and fell in love with it. It got me thinking about the plight of the newcomer to SQL Server...  So if you are the accidental DBA, or, simp…
In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

920 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now