?
Solved

SQL Question_New

Posted on 2013-01-13
2
Medium Priority
?
336 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 22

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

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

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 …
by Mark Wills PIVOT is a great facility and solves many an EAV (Entity - Attribute - Value) type transformation where we need the information held as data within a column to become columns in their own right. Now, in some cases that is relatively…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

764 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