Last files N in a table
Hi Experts, how to extract the last N records from a table without altering the order of records?
Thanks in advance...
Hello
2763326 wrote:
Hello
Sorry, I was on vacation and could not answer soon.
I went through the discussion that happened. Thank you all for your time.
I clarify my question as below:
The emp table I get two last records i.e., registration of FORD and MILLER
EMPNO, ENAME JOB MGR, HIREDATE SAL COMM DEPTNO ------ ---------- --------- ---------- --------- ---------- ---------- ----------
7369 SMITH | CLERK | 7902 DECEMBER 17, 80 | 800 | 20 | |
7499 ALLEN | SELLER | 7698 FEBRUARY 20, 81 | 1600 | 300 | 30 |
7521 WARD | SELLER | 7698 FEBRUARY 22, 81 | 1250 | 500 | 30 |
7566 JONES | MANAGER | 7839 2 APRIL 81 | 2975 | 20 | |
7654 MARTIN | SELLER | 7698 28 - SEP - 81 | 1250 | 1400 | 30 |
7698 BLAKE | MANAGER | 7839 1 MAY 81 | 2850 | 30 | |
7782 CLARK | MANAGER | 7839 JUNE 9, 81 | 2450 | 10 | |
7788 SCOTT | ANALYST | 7566 APRIL 19, 87 | 3000 | 20 | |
KING 7839 | PRESIDENT | NOVEMBER 17, 81 | 5000 | 10 | |
7844 TURNER | SELLER | 7698 08 - SEP - 81 | 1500 | 0 | 30 |
7876 ADAMS | CLERK | 7788 MAY 23, 87 | 1100 | 20 | |
JAMES 7900 | CLERK | 7698 DECEMBER 3, 81 | 950 | 30 | |
7902 FORD | ANALYST | 7566 DECEMBER 3, 81 | 3000 | 20 | |
7934 MILLER | CLERK | 7782 JANUARY 23, 82 | 1300 | 10 |
OUTPUT:
7902 FORD | ANALYST | 7566 DECEMBER 3, 81 | 3000 | 20 |
7934 MILLER | CLERK | 7782 JANUARY 23, 82 | 1300 | 10 |
Is it possible to get this result from the discussion I see that oracle does not maintain insertion order unless you have a specific column to keep track of changes and insertions.
Thanks in advance
Ravi
Of course; If you can tell which way these 2 rows are the last 2: can someone show you how do it.
They are the last 2 in order by empno? If so:
WITH got_r_num AS
(
SELECT ename, empno, mgr, hiredate, sal, comm, deptno
, EVALUATE () OVER (ORDER BY empno DESC) AS r_num
FROM scott.emp
)
SELECT ename, empno, mgr, hiredate, sal, comm, deptno
OF got_r_num
WHERE r_num<=>=>
;
Is this another thing that makes the last 2 rows? If so, change the analytical ORDER BY clause.
Tags: Database
Similar Questions
-
jump the last record loading using external table
Hi gentlemen,
I have a requirement to load data from text file of oracle database by using the external table. I need to remove the header records and complementary.
I can use the skip option to remove the header, IE front-line.
Is it possible to remove the additional record (IE last line) using the external table.
Thanks in advance.
FerryHello ferry.
Do not hesitate on occasion as useful and Correct answers for those of us Newbie trying to get credibility :)Thank you
Luke -
Get the error loading file csv to oracle table
Hello
I'm tryitng to load the csv file into oracle db table.
Source:
CSV file have account_numbers, customer_names. all the fields, it took as channel.
Target: Oracle db
If I took all the fields as varchar, it loads very well. but I want to
Oracle table fields: digital account numbers or decimal (20.2)
customer_names as varchar2 format.
When I'm trying to load csv to oracle table, I am getting following error.
ODI-1228: fgh1 (integration) task fails on the target odi_user1 ORACLE connection.
Caused by: java.sql.SQLSyntaxErrorException: ORA-01722: invalid number
I tried so many times. I am still getting error.
TO_NUMBER function I also used, getting same error
Please help me,
Thank you and best regards,
A.Kavya.
Hi, String, CSV file data type have values of amount a 54,356,4657.89 format. Like this. In odi, I took number (30.2) of data types for the target table. When I traced in odi, I get error like invalid number. to do this, I changed the values in csv file format. I removed commas. for example, 543564657.89. Yet once, I traced csv to oracle in odi. executd successfully. Thanks & regards, A.kavya.
-
Load the XML file into Oracle external Table
I load the data from the XML file into an intermediate table Oracle using external Tables.Let's say below, it is my XML file
< header >
< A_CNT > 10 < / A_CNT >
< E_CNT > 10 < / E_CNT >
< AF_CNT > 10 < / AF_CNT >
< / header >
< student >
<>students-details
< Student_info >
< Single_Info >
< ID > 18 / < ID >
New York < City > < / City >
< country > United States < / country >
< Name_lst >
< Student_name >
Samuel < name > < / name >
Paul < Last_name > < / Last_name >
< DOB > 19871208 < / DOB >
Aware of < RecordStatus > < / RecordStatus >
< / Student_name >
< Student_name >
Samuel < name > < / name >
Paul < Last_name > < / Last_name >
< DOB > 19871208 < / DOB >< TerminationDt > 20050812 < / TerminationDt >
History of < RecordStatus > < / RecordStatus >
< / Student_name >
< / Name_lst >
< Personal_Info >
<>men < / Type >
< 27 > < / Age >
< / Personal_Info >
< / Single_Info >
< / Student_info >< student - register >
class < A >
< info >
< detail >
< ID student > 18 < / student >
EE < major > < / Major >
< course-Grades >
< course > VLSI < / course >
< degree > 3.0 < / Grade >
< / course-Grades >
< course-Grades >
< course > nanotechnology < / course >
< degree > 4.0 < / Grade >
< / course-Grades >
< / details >
< detail >
< ID student > 18 < / student >
THIS < major > < / Major >
< / details >
< / info >
class < A >
< Student_Enrol >
<>students-details
< student >I load this XML data file into a single table using an external Table. Could someone help me please with coding.
Thank you
Reva
Could you please help me how to insert my XML content into that.
Same as before, try a plain old INSERT:
insert into xml_pecos
values)
XmlType (bfilename ('XML_DIR', "test.xml"), nls_charset_id ('AL32UTF8'))
);
But you'll probably hit the same limitation as with the binary XMLType table.
In this case, you can use FTP to load the file as a resource in the XML DB repository.
If the XML schema has been registered with the hierarchy enabled then the file will be automatically inserted into the table.
Could you post the exact statement that you used to save the scheme?
In the meantime, you can also read this article, I did a few years ago, it covers the XML DB features that may be useful here, including details on how to load the file via FTP:
https://odieweblog.WordPress.com/2011/11/23/Oracle-XML-DB-a-practical-example/
And documentation of the course: http://docs.oracle.com/cd/E11882_01/appdev.112/e23094/xdb06stt.htm#ADXDB4672
-
How can I add data file to an existing table on Oracle RAC ASM with no OMF? Thank you!
How can I add data file to an existing table on Oracle RAC ASM with no OMF? Thank you!
Hello
So I guess you have some files in ASM, see your first existing file structure
Select file_name
from dba_data_files;
and to add to an existing table, the example below (even if you're better sticking with OMFs!)-is that what you are looking for?
SQL > create tablespace TEST1
2 datafile '+ DATA' size 1 M;
Created tablespace.
SQL > select file_name in dba_data_files;
FILE_NAME
--------------------------------------------------------------------------------
+Data/orcl2/datafile/users.259.859820983
+Data/orcl2/datafile/undotbs1.258.859820983
+Data/orcl2/datafile/SYSAUX.257.859820983
+Data/orcl2/datafile/system.256.859820981
+Data/orcl2/datafile/example.269.859821049
+Data/orcl2/datafile/Test1.271.859843053
6 selected lines.
SQL > alter tablespace TEST1
2 Add datafile ' + DATA / mynewfile01.dbf ' size 2 m;
Tablespace altered.
SQL > select file_name in dba_data_files;
FILE_NAME
--------------------------------------------------------------------------------
+Data/orcl2/datafile/users.259.859820983
+Data/orcl2/datafile/undotbs1.258.859820983
+Data/orcl2/datafile/SYSAUX.257.859820983
+Data/orcl2/datafile/system.256.859820981
+Data/orcl2/datafile/example.269.859821049
+Data/orcl2/datafile/Test1.271.859843053
+ DATA / mynewfile01.dbf
Thank you
-
Select the last 10 records in a table
Oracle9i. I am trying to select the last 10 numbers in a table with this command series
but it's not not selecting the most recent serial number 10. How to do?select serial from tab_42 where employeecode='00001' and rownum<=10 order by serial desc;
The rownum clause is applied before the order by clause, one must use a subquery...
select * from (select serial from tab_42 where employeecode='00001' order by serial desc) where rownum<=10;
-
How to identify the last instance of a dynamic table row
Hi all
I'm trying to figure out how to create an action for my form in Livecycle Designer ES2, which will affect the last instance of a dynamic table row. I have a table with a repeatable row where the user will enter information about a part purchased and I have buttons that allow the user to add and remove the lines. I need to create a line extra addition button which will add a new instance of the repeatable table line (this is not a problem) and disable and change the background color of the first cell in the row added. The problem I have is how to have an action that affects the last instance of a line.
If anyone knows how to do this in Javascript, I would appreciate some advice/help.
Hello
I think that it is beyond providing an action. You will have a need to write JavaScript directly. When you call the addInstance method it returns the new line, if you can do something like;
var line = Table1._Row1.addInstance ();
line. TextField1.border.fill.color.value = "255,0,0";
line. TextField1.access = 'protected ';
To find the last line and do the same thing, you can do something like;
var line = Table1.resolveNode ("Row1 [" + (Table1._Row1.count - 1) + "" "]" ");
line. TextField1.border.fill.color.value = "255,0,0";
line. TextField1.access = 'protected ';
Concerning
Bruce
-
to insert two text file into an oracle table
Hi all
I am new to oracle technology. I want to insert data into the table using two text files...
FOR EXAMPLE:
Text1.txt contains employe_id, Employee_name, address
Text2.txt contains department_id and department_name
I want to insert data in the table employee having column employee_id, employee_name, department_name, department_id and address...
Using the unique control file I want to solve say... I Googled it, but I can't have any idea...Hi, we use the concept of external Tables...
First table with Text1 file using...
(Text1) CREATE TABLE
number of employe_id, employee_name VARCHAR2 (50)
)
(EXTERNAL) ORGANIZATION
TYPE ORACLE_LOADER
THE DEFAULT DIRECTORY HFO_CONS_INPUT<-- directory="">-->
(SETTINGS) ACCESS
RECORDS DELIMITED BY NEWLINE
FIELDS TERMINATED BY ', '.
MISSING FIELD VALUES ARE NULL
(
employee_id char(10),
Employee_Name CHAR (50))
)
LOCATION ('text1.txt')
)
5 PARALLEL
REJECT LIMIT UNLIMITED;2 text file:
(Text2) CREATE TABLE
department_id number, department_name VARCHAR2 (50)
)
(EXTERNAL) ORGANIZATION
TYPE ORACLE_LOADER
THE DEFAULT DIRECTORY HFO_CONS_INPUT
(SETTINGS) ACCESS
RECORDS DELIMITED BY NEWLINE
FIELDS TERMINATED BY ', '.
MISSING FIELD VALUES ARE NULL
(
department_id char(10),
department_name CHAR (50)
)
)
LOCATION ("text2.txt")
)
5 PARALLEL
REJECT LIMIT UNLIMITED;Then,
Select * from text1, text2;
EMPLOYEE_ID EMPLOYEE_NAME ADDRESS DEPARTMENT_ID DEPARTMENT_NAME
1212 Maduravoyal ka 892390 computers
Thank you
Shankar -
How to select the last 20 transactions in a table
Hi guys,.
I have a table named INOUT with following columns
EMPLOYEECODE VARCHAR2
DATE OF THE RESPONDENT
each day employees now their me 'in '. then entered came and came in this table. If we want to select the last 20 EMPLOYEECODE in this table that make their selves 'in '. How to choose that? just 20 last employees who traded. Help, pleaseHello
This is called a Query Top - N , you want to choose elements of N (N = 20, in this case) from the top of a sorted list.
Here's a way to do it:WITH got_r_num AS ( SELECT emloyeecode , MAX (intime) AS latest_intime -- If wanted , RANK () OVER (ORDER BY MAX (intime) DESC) AS r_num FROM inout GROUP BY employeecode ) SELECT employeecode , latest_intime -- If wanted , r_num -- If wanted FROM got_r_num WHERE r_num <= 20 ;
That actaully could take more than 20 people: If there be a tie, it includes any person who is entitled to be in the top 20. If you want exactly 20 people, then add the columns of tiebreaker to analytical or use ROW_NUMBER instead of RANK ORDER BY clause.
-
How to stop the last file opened at startup?
InDesign CS5 insists on reopening of the last file opened whenever I run the app, I had. I tried making sure that all documents are closed before leaving ID without success. I have looked through preferences but can't seem to find anything that changes. I'm on a Mac under Lion (10.7.4) and sought a solution to operating system level but haven't found anything, and no other application behaves like that. I search these forums and have not found an answer.
Someone out there has an idea or is it an isolated case? Thank you.
Mike
Too bad. Found the answer-
-
Is anyone else having CS5 opens the last file automatically (whether they like it or not)? -from time to time it seems this causes an accident as well!
Is there a way to disable this option?
This can help:
http://www.Macworld.com/article/1166029/tame_lions_resume_features.html
-
Select the last disk in the history table
How to select the last record in a history table? the example data is
< p >
Product EffectiveDate
prod1 01/01/1980
prod1 01/01/1990
prod1 01/01/2000
prod2 02/02/1980
prod2 02/02/2000
< /p >
< p >
The expected result is
Product EffectiveDate
prod1 01/01/2000
prod2 02/02/2000
< /p >
Assuming that there is a single line with max (effectivedate) for a given product
SELECT product, attrib1, attrib2, ... , max_effective_date FROM (SELECT product, attrib1, attrib2, ... , effectivedate, max( effectivedate ) over (partition by product) max_effective_date FROM history_table) WHERE effectivedate = max_effectivedate
should work.
Justin
Published by: Justin cave on October 30, 2008 18:32
Formatting changes
-
How to convert a text file and give the table
Hai
How to convert a text file and give the data of the tableISN'T THERE!
You must put this
SET_BLOCK_PROPERTY ('TEST_MS', insert_allowed, property_false);
SET_BLOCK_PROPERTY ('TEST_MS', update_allowed, property_false);just before the last exception...
Published by: Dora on January 19, 2010 14:54
-
Select several files and store in table: folder object type turns into a string?
Hello
I'm trying to implement the following:
The user selects a folder (which contains subfolders) in a dialog box:
Set Dateiauswahl = CreateObject. BrowseForFolder (0, "Verzeichnis Park", 512, mess_path)
Folder value = CreateObject ("Scripting.FileSystemObject"). GetFolder (Dateiauswahl.Self.Path)
All subfolders of the selected folders are listed in two variables with the overall picture:
Call GlobalDim ("FolderList (" & Ordner.SubFolders.Count - 1 & "" ")" ")
Call GlobalDim ("FolderPaths (" & Ordner.SubFolders.Count - 1 & "" ")" ")
f = 0
for each Unterordner in Ordner.SubFolders
FolderList (f) = Unterordner.Name
FolderPaths (f) = Unterordner
f = f + 1next
Only later the files of some of the subfolders should be stored in another file list table:
f = 0
for q = 0 to UBound (selection)
Unterordner = FolderPaths (selection (q))
Call MsgBox (Unterordner)
For each file in Unterordner.Files
If instr (1, File.Name, "Speed") = 0 then
FileList (f) = File.Path
f = f + 1
end if
Nextnext
Now I seem to have a problem with the type data stored in the FolderPaths table. While Unterordner is a Folder object and must be a Folder object for each file in Unterordner.Files to work, store in the array it transformed into a string variable.
I don't really understand why and am looking for a solution so that I can extract single table FolderPaths subfolders and then extract the files.
Hi maliya,.
To assign an object to an array element (or any other variable), you must use the Set syntax, like this:
Set FolderPaths (f) = Unterordner
Then later you can retrieve it with the same syntax:
Set Unterordner = FolderPaths (selection (q))
Brad Turpin
Tiara Product Support Engineer
National Instruments
-
How to view the last element in a dynamic table 1 d
Hello..
I want to display the value of the last element in a dynamic array 1 d... / I mean... If I stop the vi race, I need to display the last element of the array... How can I do this?
and is it possible to use a button to start the vi... instead of using the Run button on the face before of the vi?
An array of index!. Size of table allows to determine the size of your array, subtract 1, that feed into the terminal array of Index index.
You start the VI running somehow. It can be assigned to run when opening. Assuming that what you want is a way to type values in a front panel, press a GO button you created on the front panel, then have the real part of the VI to run. You can use a structure of the event. Or put a while loop at the beginning with a small wait next statement which basically just asks the GO button. When you press this button, the Boolean value true stops the whole loop and allows the program to move on the main body of your program.
Maybe you are looking for
-
Is there a way to tag audio files on an ipod nano 8th generation and iphone?
Hello I listen to audio long music mixes and podcasts radio, usually between 2 to 4 hours long. But many times, I want to set up. I would to halfway through listening to a mix of music for 2 hours, then to go to the podcast. But then I don't want to
-
FF 27 - my fonts are pixely and I can't understand why.
Hello friends, About 4 weeks ago, fonts on all the pages I visit using Firefox became pixely (some letters appear in bold, the lines seem to be low resolution, etc.). I tried the following steps to fix without success: -Update of FF 27-Reset by defau
-
When the application opens, I can't access leaderboard. My score is also incorrect when the application opens. When I click on the game my score is correct. I play for a long time trying to climb in the standings and can there access is no longer. I
-
short blue screen followed by automatic restart after installing Windows updates
Remember - this is a public forum so never post private information such as numbers of mail or telephone! Ideas: after installing the latest updates of window automatically I'll briefly a blue screen and then restart. I fixed it by unscrewing the 4 u
-
Need to reinstall Vista, but don't have a recovery disk or a Vista disk
Hello. I have a Sony Vaio CR series (model VGN-CR36G/B) laptop. It comes with Windows Vista Home Premium OEM. I don't have a disk of Vista when I bought my computer. Also, I received no recovery discs, although I had a recovery partition set up on to