Query user last logon time issue

Source: Internet
Author: User

Today, there is a seemingly simple but very tangled problem, but finally solved the

I'm using Oracle based on a lot of things that are available online, specific stickers

This is the field of the login table, which inserts the user's ID login time when each user logs in

Now the user wants to show the last logon time how to take?

Here's the flashback of the landing time.

If you take the latest login time as follows

But how to take the last login record (that is, the second one after the flashback)? Online offers a lot of is to let rownum=2, but the results are greatly unexpected

It is empty value, that is, and not to take it, but if you change to rownum<=2 can get the first two articles:

I am also very puzzled about what is going on, finally can only take the 2 data to do a sort, take the first one,

Although this is taken out but the total feeling of some discomfort, there should be a more feasible way, I hope the great God to give guidance.

Another doubt is that if you look directly at ROWNUM the result is:

It is because he is not in the order of time to gradually increase, so even let rownum=2 go to the wrong.

Hope that the way the great God pointing Maze!!!

Reproduced please indicate the original, thank you!

Query user last logon time issue

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.