Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

limiting return values

Posted on 2005-04-26
2
Medium Priority
?
180 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
[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 28

Accepted Solution

by:
rafrancisco earned 400 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
When trying to connect from SSMS v17.x to a SQL Server Integration Services 2016 instance or previous version, you get the error “Connecting to the Integration Services service on the computer failed with the following error: 'The specified service …
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.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

618 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