troubleshooting Question

How do I extract the TOP 1 from a list

Avatar of Chris Michalczuk
Chris MichalczukFlag for United Kingdom of Great Britain and Northern Ireland asked on
Microsoft SQL Server
6 Comments1 Solution51 ViewsLast Modified:
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
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 6 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 6 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros