Solved

limiting return values

Posted on 2005-04-26
2
174 Views
Last Modified: 2010-03-19
I need to bring back the first of N entries in a table with multiple records of the same account number. There is a mdate in the table and I want the data associated with the latested mdate.

Thanks,
Rut
0
Comment
Question by:rutledgj
2 Comments
 
LVL 28

Accepted Solution

by:
rafrancisco earned 100 total points
ID: 13868924
Try this:

SELECT *
FROM YourTable A
WHERE MDATE = (SELECT MAX(MDATE) FROM YourTable B
                           WHERE A.AccountNo = B.AccountNo)
0
 
LVL 34

Expert Comment

by:Brian Crowe
ID: 13868950
Not sure if this is what you're looking for...

CREATE PROCEDURE myProc
     @AccountNumber int,
     @mdate datetime,
     @Rows int
AS

SET ROWCOUNT @Rows

SELECT ... FROM myTable WHERE AccountNumber = @AccountNumber AND mdate = @mdate

SET ROWCOUNT 0
GO

0

Featured Post

Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

Question has a verified solution.

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

Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

867 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

20 Experts available now in Live!

Get 1:1 Help Now