Solved

SQL Question_New

Posted on 2013-01-13
2
322 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
Comment Utility
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
Comment Utility
Thanks. Actually, I had done it myself  and just double checking.
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

So every once in a while at work I am asked to export data from one table and insert it into another on a different server.  I hate doing this.  There's so many different tables and data types.  Some column data needs quoted and some doesn't.  What …
INTRODUCTION: While tying your database objects into builds and your enterprise source control system takes a third-party product (like Visual Studio Database Edition or Red-Gate's SQL Source Control), you can achieve some protection using a sing…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

743 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

18 Experts available now in Live!

Get 1:1 Help Now