Solved

SQL Question_New

Posted on 2013-01-13
2
324 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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

Introduction This article will provide a solution for an error that might occur installing a new SQL 2005 64-bit cluster. This article will assume that you are fully prepared to complete the installation and describes the error as it occurred durin…
In SQL Server, when rows are selected from a table, does it retrieve data in the order in which it is inserted?  Many believe this is the case. Let us try to examine for ourselves with an example. To get started, use the following script, wh…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.

786 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