473,395 Members | 1,639 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Retriving Last ten modified Records

3
Hi All,

How can i select last ten modified records in table.

Can u please help me.
Feb 24 '07 #1
18 30673
vijaydiwakar
579 512MB
Hi All,

How can i select last ten modified records in table.

Can u please help me.
dear i think there is no such provision but u may do one thing create a trigger after update add one field lastmodified as date
this trigger will then auto save the current sysdate in that column and then ur able to retrive the data
try it
Feb 27 '07 #2
Hi All,

How can i select last ten modified records in table.

Can u please help me.

Dear ,

Try rownum pseudocolumn to find out the last 10 records

like select rownum,ename,sal from emp;

Zafar Iqbal
Mar 2 '07 #3
Hi All,

How can i select last ten modified records in table.

Can u please help me.

Hello Dear,

Try this

select rownum from emp
group by rownum
having rownum >=(select max(rownum)-10 from emp)

hope it works

Zafar Iqbal
Karachi
Mar 2 '07 #4
vijaydiwakar
579 512MB
Hello Dear,

Try this

select rownum from emp
group by rownum
having rownum >=(select max(rownum)-10 from emp)

hope it works

Zafar Iqbal
Karachi
no dear the rownum doesnot work properly or u may say in that manner in which ur expecting
to see how try to use subqry with rownum in both qry
Mar 2 '07 #5
no dear the rownum doesnot work properly or u may say in that manner in which ur expecting
to see how try to use subqry with rownum in both qry

- Have you a date_modified column in your table?
if it's the case. Why you don't use this :

select * from
( select * from yourtable order by date_modif desc)
where rownum <= 10
Mar 2 '07 #6
no dear the rownum doesnot work properly or u may say in that manner in which ur expecting
to see how try to use subqry with rownum in both qry
My query will retrieve last ten inserted record. I will try to
find last ten modified records.

Zafar Iqbal
Mar 3 '07 #7
Rks
3
dear i think there is no such provision but u may do one thing create a trigger after update add one field lastmodified as date
this trigger will then auto save the current sysdate in that column and then ur able to retrive the data
try it
Thanks for your update vijay,

I try this one and get back to you once completed.

Thanks,
Ramesh S
Mar 3 '07 #8
Rks
3
Hello Dear,

Try this

select rownum from emp
group by rownum
having rownum >=(select max(rownum)-10 from emp)

hope it works

Zafar Iqbal
Karachi

Can u plz explain this query, i am confused.
Mar 3 '07 #9
Dave44
153 100+
I dont beleive you can use rownum by itself. the reason is that when rows are deleted from a table newly inserted rows are put in its place, so if you query by rownum the newly inserted row may not be in the last 10 rows of the table (which is all rownum is without some kind of order by in the query).

even a date_modified column may not work unless you just want some of the last 10 records modified even if 20 records were modified at the same time. if that's the case then you could select all the rows from the table ordered by the modified date desc and then grab the first 10 rows using your rownum psuedo column.
Mar 3 '07 #10
[hi all:

how can i get he third largest salary from a table that contain salaries of all employees.
Mar 5 '07 #11
Dave44
153 100+
[hi all:

how can i get he third largest salary from a table that contain salaries of all employees.

This will get it for you, it uses an analytic function that gives a row a number based upon values provided in the window clause. you should learn about analytics... there are very useful at times.

Expand|Select|Wrap|Line Numbers
  1. SELECT a.salary
  2. FROM   (SELECT   salary,
  3.                  ROW_NUMBER() OVER(ORDER BY salary DESC) my_row_number
  4.         FROM     my_salary_table
  5.         ORDER BY salary DESC) a
  6. WHERE  my_row_number = 3
  7.  
Mar 7 '07 #12
How to get the last modified row? only one that is lastly modified....
Nov 17 '07 #13
in sql server I use profiler and works fine for all such needs
Feb 23 '10 #14
OraMaster
135 100+
Is there any date (like add_date or M mod_date) type column you have in table.

Expand|Select|Wrap|Line Numbers
  1. SELECT *
  2.   FROM (SELECT ROWNUM seq, lat_rec.*
  3.           FROM (SELECT   <tablename>.*
  4.                     FROM <tablename>
  5.                 ORDER BY GREATEST (admitdt, moddt) DESC) lat_rec)
  6.  WHERE seq < 11
Hope this will help you.
Feb 25 '10 #15
I think vijaydiwakar is right. b'coz oracle creates the rownum when a record is inserted into a table but not at the time of update in the record so it not possible to select the last updated records using the rownum, rather u have to add one more column say Updated which will contain the date on which the record is lastly updated.
Mar 17 '10 #16
OraMaster
135 100+
DipakYadav,
Oracle doesn't create ROWNUM at the time of insertion. It's ROWID which gets created for each row when insertion happens. Oracle assigns unique number to each record at the time of select/update in the order it fetches the record from tables.
Mar 17 '10 #17
@rathinavelpec
u cant really say,,when your last modify is used...

1.u may use modify command...
2.u may use alter command...
3.u may use update command....

so the records can be anywhere with in the table....
also you may modify or delete or alter or update before,hour,day,month,year,, we dont have perfection in oracle sql..

but we can get the last row inserted....which is utmost last

select * from emp where rowid=(select max(rowid) from emp);
Dec 5 '11 #18
select * from emp where 2=(select count(*) from emp e where emp.sal<e.sal);

its also return the 3 hight sal
Jul 12 '18 #19

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Amanda | last post by:
Hi, hope you can help me with this one. If I want to get the date a page has been last modified, I can do something like .. document.write("<b>Last updated: "+document.lastModified+"</b>"); ...
11
by: Dennis Marks | last post by:
There seems to be a major program with the automatic display of the last modified date. Using the javascript "document.lastModified" sometimes returns the correct date and sometimes 1 Jan 1970...
7
by: laredotornado | last post by:
Hello, Does anyone know how (or if) I can figure out the last time a web page was last modified if my only access to it is via HTTP (a web browser). Right now, I'm looking at "Page Info" options....
12
by: savedelhi | last post by:
Hi, I'm a relative newby and have a tricky problem in Access 2002. I have a continuous form with a check box called "Select". (I now know I shouldn't have called it that but it's way too late...
2
by: asma410 | last post by:
Is it possible to display the file created & file modified information on a switchboard? I have designed the database so that when the user clicks on an icon on the switchboard, a form (linked to a...
3
by: RAMohrmann | last post by:
Greetings, I am attempting to view all files in a directory and if those files have not been modified within the last couple days I will remove them. In order to do this I need to look at the...
9
by: mazen.s.m | last post by:
I have been trying to find a way to get the Domain and UserName of the user that last modified a file. I know how to get the owner of the file via WMI or Win32, but I can't find a way to get the...
1
by: Svetac | last post by:
Hi, I use a script that shows when the page was last modified. It works fine for just one html file. The thing I would like to do is that the script shows me of last modified file in root...
3
by: Gretsch | last post by:
Web, html, javascript, Hi, I need to calculate the time since this .htm file was last modified. {which I can then use in a calculation, rather than display, so days&decimals format would be OK}...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.