troubleshooting Question

SQL Query Help

Avatar of Arikkan
ArikkanFlag for United States of America asked on
Microsoft SQL Server 2008Oracle DatabaseDatabases
6 Comments3 Solutions100 ViewsLast Modified:
I have a list of Users in the system with User ID's, Application ID they accessed & sequence number for each step.  
Now I want to select a list of the latest applications accessed by user (With Sequence numbers).

Complete List
----------------------------------------------------------------------
|  User#  |    Application#       |     Sequence#    |
|      1       |              4                 |              1             |  
|      1       |              4                 |              2             |  
|      1       |              4                 |              3             |  
|      1       |              5                 |              1             |  
|      1       |              5                 |              2             |  
|      1       |              5                 |              3             |  

|      1       |              9                 |              1             |  
|      1       |              9                 |              2             |  
|      1       |              9                 |              3             |  
|      2       |              7                 |              1             |  
|      2       |              7                 |              2             |  
|      2       |              7                 |              3             |  
|      2       |              3                 |              1             |  
|      2       |              3                 |              2             |  
|      2       |              3                 |              3             |  

----------------------------------------------------------------------


Filtered List needed (Assume that each Application has a time-stamp used for access (We can compare time-stamps and let the latest application accessed for each user):
----------------------------------------------------------------------
|  User#  |    Application#       |     Sequence#    |
|      1       |              4                 |              1             |  
|      1       |              4                 |              2             |  
|      1       |              4                 |              3             |  
|      2       |              3                 |              1             |  
|      2       |              3                 |              2             |  
|      2       |              3                 |              3             |  
|               |                                  |                             |  
----------------------------------------------------------------------


Assume that the fields on the Table are "UserID", "ApplicationID", "SeqID".
The constraint is that I want the second list records in the same List order as the first. If user "1" comes before in the First list then that users records (All grouped records for the application selected) will come before in second list and so on.

Any ideas on how to format the Query?

Please let me know if I am not clear.
SOLUTION
Log in to continue reading
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform for $9.99/mo
View membership options
Unlock 3 Answers and 6 Comments.
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
The Value of Experts Exchange in My Daily IT Life

Experts Exchange (EE) has become my company's go-to resource to get answers. I've used EE to make decisions, solve problems and even save customers. OutagesIO has been a challenging project and... Keep reading >>

Mike

Owner of Outages.IO
Phoenix, Arizona, United States
Member Since 2016
Join a full scale community that combines the best parts of other tools into one platform.
Unlock 3 Answers and 6 Comments.
View membership options
“All of life is about relationships, and EE has made a virtual community a real community. It lifts everyone's boat.”
William Peck

Member since 2004