Solved

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

Posted on 2009-07-14
1
183 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 250 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

Technology Partners: 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

JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.

707 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