We help IT Professionals succeed at work.
Get Started

How do I extract the TOP 1 from a list

46 Views
Last Modified: 2016-01-18
How do I show only the last issuenumber for a sequencenumber in a list - this is my query but I get the results as show below
I only want the results to show the 2 lines marked with *********** below

SELECT
      [ACCOUNTID]
      ,[SEQUENCENUMBER]
      ,[ISSUENUMBER]
   
  FROM temp1
  where accountid='A6UJ9A000AAQ'
  order by  [SEQUENCENUMBER],ISSUENUMBER desc

  select  SEQUENCENUMBER, issuenumber FROM temp1
  where accountid='A6UJ9A000AAQ'
  group by SEQUENCENUMBER,issuenumber

  order by  [SEQUENCENUMBER] desc ,issuenumber desc



ACCOUNTID      SEQUENCENUMBER      ISSUENUMBER
A6UJ9A000AAQ      4264      14  *********************
A6UJ9A000AAQ      4264      13
A6UJ9A000AAQ      4264      12
A6UJ9A000AAQ      4264      11
A6UJ9A000AAQ      4264      10
A6UJ9A000AAQ      4264      9
A6UJ9A000AAQ      4264      8
A6UJ9A000AAQ      21600      1 ********************
A6UJ9A000AAQ      21600      0
Comment
Watch Question
IT Engineer
CERTIFIED EXPERT
Distinguished Expert 2017
Commented:
This problem has been solved!
Unlock 1 Answer and 6 Comments.
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