?
Solved

SQL to retrieve the last receipt an individual was included in.

Posted on 2009-07-14
1
Medium Priority
?
186 Views
Last Modified: 2012-05-07
Hi,
I'm looking at trying to determine, for each member in the system, the last receipt they appeared on. The tables look as follows (in brief):

Receipts: Unqiue ID, Member ID, Receipt Date

Each member can appear multiple times in the table. What I want is, for each member, provide me the unique ID for the last receipt they appeared on based on receipt date.

THanks.
0
Comment
Question by:bryan_z
[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
1 Comment
 
LVL 17

Accepted Solution

by:
pssandhu earned 1000 total points
ID: 24851212
Select *
From  Receipts r inner join (Select MemberID, MAX(ReceiptDate) Date From receipts Group by MemberID) m
          ON r.memberID = m.memberid and r.ReceiptDate = m.Date
P.
0

Featured Post

Congratulations! You’re Certified – Now What?

Starting a new career can be overwhelming. Becoming certified in your field of expertise is a great start, but where do you go from here?  Here are some tips to help you on your career journey.

Question has a verified solution.

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

I'm trying, I really am. But I've seen so many wrong approaches involving date(time) boundaries I despair about my inability to explain it. I've seen quite a few recently that define a non-leap year as 364 days, or 366 days and the list goes on. …
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.
Suggested Courses

752 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