We help IT Professionals succeed at work.
Get Started

Select statement Query SQL

184 Views
Last Modified: 2015-07-01
Hi Experts,
I need to create this report in sql by selecting the last record for each referralID. As you see below in the table i have the same referralID many times and i need to select 1 record per each referralID. That would be the last one entered, or the one with highest number of "StatusUpdateID". Suggestions?

Here is how the table looks like.
StatusUpdateID          ReferralID         Q1         Q2             Q3
1                                    685                      1           1                 2
2                                    685                      1            1                 1
3                                    685                      1           0                 0
4                                    688                       0           0                 1
5                                    688                      1            1                 1
6                                    689                      1              1               1
Comment
Watch Question
Senior DBA
CERTIFIED EXPERT
Most Valuable Expert 2018
Distinguished Expert 2019
Commented:
This problem has been solved!
Unlock 1 Answer and 1 Comment.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE