Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7968137
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T07:01:47+00:00 2026-06-04T07:01:47+00:00

I have some data in a format described in this sqlfilddle: http://sqlfiddle.com/#!4/b9cdf/2 Basically, a

  • 0

I have some data in a format described in this sqlfilddle: http://sqlfiddle.com/#!4/b9cdf/2

Basically, a table with a user ID and a time that an event occured. What I’d like to do is count the events based on the time they happened by user. So, a table that looks like:

UID    Timestamp
-----------------
01     01-APR-12
01     01-APR-12     
02     02-APR-12     
03     05-APR-12     
01     10-APR-12     
02     11-APR-12     
03     15-APR-12     
01     20-APR-12     

I want this to assign a numerical rank to the events based on the order in which they occurred. So, this means the table above would become:

UID    Timestamp     Rank
--------------------------
01     01-APR-12     1
02     02-APR-12     1
03     05-APR-12     1
01     10-APR-12     2
02     11-APR-12     2
03     15-APR-12     2
01     20-APR-12     3

Is there a way to do this in Oracle SQL? Or do I have to spit it out to a scripting language and take it from there?

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T07:01:48+00:00Added an answer on June 4, 2026 at 7:01 am

    It looks like you want the analytic function rank

    SELECT uid, timestamp, rank() over (partition by uid order by timestamp) rnk
      FROM your_table
    

    If there can be ties (two rows with the same UID and Timestamp) then, depending on how you want to handle ties, you may want the dense_rank or row_number analytic function instead.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some data in the database, in this format: Description~Level||Description~Level|| I want to
I have some text data in this format: MI 00 3 MD 1 0.0000
I have some data in this format: one,one two,two sub_one,one sub_two,two sub_sub_one,sub_one sub_sub_two,sub_two sub_sub_sub_one,sub_sub_one
Hi I have some data thats represented like this: 0,tcp,http,SF,239,486,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,8,8,0.00,0.00,0.00,0.00,1.00,0.00,0.00,19,19,1.00,0.00,0.05,0.00,0.00,0.00,0.00,0.00,normal. Its from the kdd
I Have some data to store, I must store this data for every user,
I have some data in the format of C222 = 50 C1234P687 = 'some
I have some data that I am displaying in 3 column format, of the
I have a log of following format << [ABC] some other data some other
I have some data in simplejson format in txt files, which I read using:
I have some data in CSV format that I want to pull into an

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.