How to select the last 3 records in a table?
I have a table named HRM_ATTENDANCEas follows
Name Type Nullable Default Comments
------------ ------------ -------- ------- --------
LEAVEDATE DATE
EMPLOYEECODE VARCHAR2(8)
LEAVETYPE VARCHAR2(4)
APPROVEDBY VARCHAR2(8) Y
FEEDBY VARCHAR2(8) Y
FEEDTIME DATE Y
REMARKS VARCHAR2(50) Y
the table contains the record of leave of employees as followsLEAVEDATE EMPLOYEECODE LEAVETYPE APPROVEDBY FEEDBY FEEDTIME REMARKS
----------- ------------ --------- ---------- -------- ----------- --------------------------------------------------
6/1/2013 00001 CL
6/3/2013 00001 EL
6/5/2013 00001 CPL
6/7/2013 00001 SL
6/9/2013 00001 CL
I want to select the last 3 leaves (records) to employeecode "00001" so I don't know the what are the dates of the leave. in easy words I want to choose the folder where leavedate > = 5 June 2013 ", but I don't know any dates."
Select * from HRM_ATTENDANCE where rownum<=3 order="" by="" leavedate="">=3>
Tags: Database
Similar Questions
-
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 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 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
-
How to select the last items of a string
Hi guys
I use the RS232 UART Protocol and I need to calculate the checksum. My data came in decimal form and in the end, it must be duplicated to handle. So my problem is, for example, the sum of all elemants is decimal 1742 in hexadecimal is 6CE and I used only the last two elemants, which corresponds to 206, which is the result of my check. Can someone help me?
Thank you
-
Need to retrieve the last line/record in a table
Hello
I have a requirement like getting the ending balance of the last record in the table and the same insertion in the opening balance of the immediatetly created the next record.
In simple terms, I need to extract a value from the last line of the recording.
For example, I use the query below
Select rownum emp, empno, ename
where rownum = (select count (rownum) from emp);
But, the above query does not return all of the recording.
Therefore, need help on this.
Kind regards
Shivakumar has
Published by: shiva March 27, 2011 22:14Hello
Strictly speaking there is no such LAST or FIRST folder until that order you them.
But check the following:SELECT * FROM emp MINUS SELECT * FROM emp WHERE rownum<=(SELECT count(empno)-1 FROM emp);
Kind regards
Lakshmi. -
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.
-
How to select the last 7 days of my table, I use the query, but it is the calculation according to sysdate
It is the data of my talble DP_DATE --------- 03-APR-10 21-APR-10 22-APR-10 23-APR-10 26-APR-10 27-APR-10 28-APR-10 29-APR-10 30-APR-10 03-MAY-10 04-MAY-10 11 rows selected.
I want to choose last 7 daysselect distinct dp_date from dailyprice where trunc(dp_date) between trunc(sysdate-7) and trunc(sysdate) this query is returning DP_DATE --------- 29-APR-10 30-APR-10 03-MAY-10 04-MAY-10
APRIL 26, 10
APRIL 27, 10
28 APRIL 10
APRIL 29, 10
30 APRIL 10
MAY 3, 10
4 MAY 10
kindly Guide
concerningHello
Use DENSE_RANK() rather than ROW_NUMBER().
with mytable as ( select 'abcFund' FND , to_date('09-MAY-10','dd-mon-rr') dp_date, 10 price from dual union all select 'dddFund', to_date('09-MAY-10','dd-mon-rr'), 12 from dual union all select 'abcFund', to_date('09-MAY-10','dd-mon-rr'), 12 from dual union all select 'edfFund', to_date('09-MAY-10','dd-mon-rr'), 12 from dual union all select 'eeeFund', to_date('09-MAY-10','dd-mon-rr'), 12 from dual union all select 'dddFund', to_date('08-MAY-10','dd-mon-rr'), 12 from dual union all select 'abcFund', to_date('08-MAY-10','dd-mon-rr'), 12 from dual union all select 'edfFund', to_date('08-MAY-10','dd-mon-rr'), 12 from dual union all select 'eeeFund', to_date('08-MAY-10','dd-mon-rr'), 12 from dual union all select 'eeeFund', to_date('08-MAY-10','dd-mon-rr'), 12 from dual union all select 'dddFund', to_date('07-MAY-10','dd-mon-rr'), 12 from dual union all select 'abcFund', to_date('07-MAY-10','dd-mon-rr'), 12 from dual union all select 'edfFund', to_date('07-MAY-10','dd-mon-rr'), 12 from dual union all select 'edfFund', to_date('05-MAY-10','dd-mon-rr'), 11 from dual union all select 'dddFund', to_date('05-MAY-10','dd-mon-rr'), 12 from dual union all select 'eeeFund', to_date('05-MAY-10','dd-mon-rr'), 12 from dual union all select 'dddFund', to_date('04-MAY-10','dd-mon-rr'), 12 from dual union all select 'abcFund', to_date('04-MAY-10','dd-mon-rr'), 12 from dual union all select 'dddFund', to_date('03-MAY-10','dd-mon-rr'), 12 from dual union all select 'abcFund', to_date('03-MAY-10','dd-mon-rr'), 12 from dual union all select 'edfFund', to_date('03-MAY-10','dd-mon-rr'), 12 from dual union all select 'eeeFund', to_date('03-MAY-10','dd-mon-rr'), 12 from dual union all select 'dddFund', to_date('01-MAY-10','dd-mon-rr'), 12 from dual union all select 'abcFund', to_date('01-MAY-10','dd-mon-rr'), 12 from dual union all select 'abcFund', to_date('30-APR-10','dd-mon-rr'), 11 from dual ) select dp_date from ( select dp_date , dense_rank() over (order by dp_date desc) rn from mytable ) where rn <= 7;
Courtesy: Rob SQL
* 009 *.Published by: 009 on May 6, 2010 05:01
-
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
-
Select the last record of each month
Hello
to select the last docnumber and qty of every month
Structure
Name Null? Type
------------------------------- -------- ----
PRODUCTCODE NUMBER
NUMBER NUMBER
DATE OF PLANFORMONTH
NUMBER OF CLEXPECTEDQTY
NUMBER OF CLCONFIRMQTY
NUMBER OF CLFGBUFFERQTY
NUMBER OF CLTOTPRINTBUFFER
in this select query if I take the sum he required all records where, as I want the last record of each month
SELECT productcode docnumber MAX (Number), planformonth, SUM (clexpectedqty) clexpectedqty (planformonth) MAX.
SUM (clconfirmqty) clconfirmqty, SUM (clfgbufferqty) clfgbufferqty, cltotprintbuffer OF FGSALESPLAN of the SUM (cltotprintbuffer)
GROUP BY productcode, (planformonth)
Sandy
Hello
Thanks its working now the code is written as below:
SELECT * FROM
(SELECT
e.*,
ROW_NUMBER() OVER (partition by PRODUCTCODE by DOCNUMBER DESC order) r
Of
E FGSALESPLAN)
WHERE r = 1 AND
entryvalid = 'Y '.
order by Number
Sandy
-
Select the last 50 closed records
The research of a statement select simple sql which selects the latest 50 records closed in the database.
I found some help out there who have an example like:
SELECT RecordID, closed_date
(SELECT RecordID, closed_date, RANK() over (ORDER BY closed_Date DESC) date_rank
FROM table1)
WHERE the date_rank < = 50;
Only problem is, this is to select something like 4000 recordings, and many of them are not yet closed.I think that you need to retrieve the records that are only closed in the first place.
Try this,
SELECT RecordID, closed_date FROM (SELECT RecordID, closed_date, ROW_NUMBER () OVER (ORDER BY closed_Date DESC) rn FROM table1 WHERE closed_date < SYSDATE) --Notice this. WHERE rn <= 50;
G.
-
How to find the last update date, time and user of the file field peoplecode
How to find the last updated date time fields of peoplecode records?
Thank you.We can check the update date-time using the following query
SELECT LASTUPDDTTM IN THE PSPCMPROG WHERE OBJECTVALUE1 LIKE "RECNAME" AND OBJECTVALUE2 AS "FIELDNAME".
-
How to restore the last backup system good
All the system fonts and icons have been changed to large size. I'm unable to locate the area where I can restore the last good record. I need to go back to the system default values that were last saved on 5 July. I don't remember how to do this. I could do it before, but can't remember where I went to get there. In addition to once, I installed a game that when close or uninstalled left all things very large sizes. How to restore the system to its original size?
try to start in safe mode by clicking the f8 during the startup key...
then run a system restore point by clicking Start > all programs > Accessories > system tools > system restore.
-
How to get the last date of 3 days for the current month?
Hello. Guy
How to get the last date of 3 days for the current month?
MY OUTPUT WOULD LOOK LIKE THIS
JANUARY 29, 2016
JANUARY 30, 2016
JANUARY 31, 2016
GUYS HELP ME / / /...
SQL > select last_day (sysdate) - level + 1 double connect by level<= 3="" order="" by="">=>
LAST_DAY)
---------
29 JANUARY 16
30 JANUARY 16
31 JANUARY 16
-
How to take the last 7 digits of a varchar column
How to take the last 7 digits of a varchar2 colum
COL1
12345678
12345
1234567890123
1234567
Out put should be as below
COL1
2345678
12345
7890123
1234567
everything built in function or in any other way please
Hello
assuming that the entry contains only numbers, as in the example, the addition of 7 spaces to the left and selecting the 7 last characters toured:
with dataset as
(select col1 from column_value
table
(dbmsoutput_linesarray
("12345678"
'12345 '.
'1234567890123'
"1234567".
)
)
)
Select col1
, substr (lpad (", 7,' ') | col1-7) col1_last7
of the dataset
/
COL1 COL1_LAST7
-------------------- --------------------
12345678 2345678
12345 12345
1234567890123 7890123
1234567 1234567
Rob
Maybe you are looking for
-
I have reset firefox have now no menu bar and pressingf alt does not work
I have reset firefox reported he turned slowly and had other problems at the start. Now, I have no menu bar and the alt button does nothing. Restored to the comp hoping that it can be useful but it did not. Any help would be appreciated.TIA.
-
Some pages do not appear like they should, I think my computer may have stopped some features when I updated my avg antivirus. I have a screenshot here. http://www.freeimagehosting.NET/newuploads/06516.jpg Thank you.
-
Original title: Bluetooth headset not connecting I have a Plantronics 9xxBackBeat headset, and I'm trying to connect my laptop (HP Pavilion dv6000) However, when pairing the headset I gives me the message "Device pairing failed. Matching attempt fail
-
(Redirected) X 51 R2 GPU Upgrade
I'm looking to upgrade my gpu. My current set up: X 51 R2 (beginning 2013) 4th gen 3.9 GHz of processor i7-4770 8 GB OF DDR3 MEMORY NVIDIA GTX 660 1.5 GB GDDR5 330W power adapter I want to upgrade to a GTX 960 but need to know if: 1. What is the maxi
-
Is it possible to print a playlist from Windows Media Player 12?
Is it possible to print a playlist of media player12? We want people to know this song is played when during the marriage. I really don't want to type everything out! original title: print a media player 12 playlist