Solved

Limit SQL Output in Excel

Posted on 2011-03-10
3
236 Views
Last Modified: 2012-05-11
I've got a Microsoft Query set up between a sql database and excel 2010 that I'm trying to filter out some information.  Attached is a copy of the report in its current state.  You'll see that the attached customer has two jobs in my system, all of which have multiple steps (Work Centers).  What I'd like to obtain is limiting the output of this script so that it only shows the first Work Center, which varies depending on the job.  Is this possible?  Attached is my SQL Code generated by Excel.  I tried using LIMIT 1 on the function at the end, but it tells me the code has errors when I apply it. "Job.Job" is the field that contains the job number, which is how I would like to limit it.  

Thank You for your help!

example.pdf
SELECT Job.Job, Job.Order_Date, Job.Customer, Job.Customer_PO, Job.Part_Number, Job.Customer_PO_LN, Job.Order_Quantity, Job.Status, Job.Sched_Start, Job.Sched_End, Job_Operation.Work_Center, Job_Operation.Status
FROM PRODUCTION.dbo.Job Job, PRODUCTION.dbo.Job_Operation Job_Operation
WHERE Job.Job = Job_Operation.Job AND ((Job.Status='Active') AND (Job_Operation.Status<>'C'))
ORDER BY Job.Customer

Open in new window

0
Comment
Question by:Kyle Witter
[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
3 Comments
 
LVL 7

Expert Comment

by:andymacf
ID: 35095398
Would the first work centre be the most recent one, if so, you could set your query to look for 'max' value on the relevant field and this will always pull in the first event.
0
 
LVL 1

Author Comment

by:Kyle Witter
ID: 35095440
The first work center is the location that the job is currently at in production.  This is the line that I would like to keep.  I guess I don't understand exactly how to set a max value to limit the output, though.

Do you have an example?  Thank you!
0
 
LVL 7

Accepted Solution

by:
andymacf earned 500 total points
ID: 35096818
Difficult to give you an example right away as I am away from my pc, but try this. In your SQL, try wrapping the value 'max(your value)… Select max(value) from
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

This article describes a serious pitfall that can happen when deleting shapes using VBA.
Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
The viewer will learn how to  create a slide that will launch other presentations in Microsoft PowerPoint. In the finished slide, each item launches a new PowerPoint presentation and when each is finished it automatically comes back to this slide: …

691 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