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, please
Hello
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.
Tags: Database
Similar Questions
-
How to select the last 3 records in a table?
I have a table named HRM_ATTENDANCE
as follows
the table contains the record of leave of employees as followsName 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
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."LEAVEDATE 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
Select * from HRM_ATTENDANCE where rownum<=3 order="" by="" leavedate="">=3>
-
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
-
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
-
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
-
Mr President, how to find the last DML operations
Hello
Please tell me how to find the last DML operations at least a minimum of 30 queries.
Thanks in advance,Select sql_id, sql_text, last_load_Time from V$ SQLAREA
or
Select * from v$ sqltext
Must be one of them. But don't know what exactly you are looking at.
I usually use v$ sqlarea to see recent queries.
Maybe you can limit the rows using rownum, order of last_load_time.
I understand, if the same query is used again then only recent transaction is stored.
-
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
-
How to get the last day of a month for every 2 months for a given period?
Hello
Can is it some please let me know how to get the last day, last day of the week, the weekend last day, last Monday, one month for every 2 months for a given period?
Thanks in advance.
Try the below
SELECT LAST_DAY (ADD_MONTHS (TRUNC(startdate,'MM'), ((LEVEL*2)-2))) lastday.
BOX WHEN TO_CHAR (LAST_DAY (ADD_MONTHS (TRUNC(startdate,'MM'), ((LEVEL*2)-2))), 'DY') = 'SAT '.
SO LAST_DAY (ADD_MONTHS (TRUNC(startdate,'MM'), ((LEVEL*2)-2)))-1
WHERE TO_CHAR (LAST_DAY (ADD_MONTHS (TRUNC(startdate,'MM'), ((LEVEL*2)-2))), 'DY') = 'Sun '.
THEN LAST_DAY (ADD_MONTHS (TRUNC(startdate,'MM'), ((LEVEL*2)-2)))-2
Of OTHER LAST_DAY (ADD_MONTHS (TRUNC(startdate,'MM'), ((LEVEL*2)-2)))
END as lastweekday,
BOX WHEN TO_CHAR (LAST_DAY (ADD_MONTHS (TRUNC(startdate,'MM'), ((LEVEL*2)-2))), 'DY') IN ('Sam', 'SUN')
THEN LAST_DAY (ADD_MONTHS (TRUNC(startdate,'MM'), ((LEVEL*2)-2)))
Of OTHER LAST_DAY (ADD_MONTHS (TRUNC(startdate,'MM'), ((LEVEL*2)-2)))
-(TO_NUMBER (TO_CHAR (LAST_DAY (ADD_MONTHS (TRUNC(startdate,'MM'), ((LEVEL*2)-2))),' from)) - 1).
END as lastweekendday,
BOX WHEN TO_CHAR (LAST_DAY (ADD_MONTHS (TRUNC(startdate,'MM'), ((LEVEL*2)-2))), 'DY') = 'MY
THEN LAST_DAY (ADD_MONTHS (TRUNC(startdate,'MM'), ((LEVEL*2)-2)))
Of OTHER NEXT_DAY (LAST_DAY (ADD_MONTHS (TRUNC(startdate,'MM'), ((LEVEL*2)-2))), "LUN")-7
END AS lastmonday
FROM (SELECT SYSDATE startdate,
SYSDATE + 300 enddate
THE DOUBLE)
CONNECT BY LEVEL<=>=>
-
How to find the last pasted paragraphs FMP?
I'm sticking FMP several objects at once in a file (a file of changes to the sections containing the changebars) in the main text flow. I want a separator line to go at the end of each pasted section, so I try to insert one after the paste operation. But instead of a line between each section, all lines are added at the end of the file, after all the sections. So if there are 3 glued sections at the end of the file are three lines. My code is below, do you know how I could fix this?
Thank you, Mark
function copyPasteChanges (doc, chgRange) {}
Select the section with changebar and copy it.
doc. TextSelection = chgRange;
doc. Copy();
Prepare for the changes doc and paste there the modified section.
var firstChgPgf = changesDoc.MainFlowInDoc.FirstTextFrameInFlow.LastPgf;
var changesTloc = new TextLoc (firstChgPgf, Constants.FV_OBJ_END_OFFSET);
var changesTRange = new TextRange (changesTloc, changesTloc);
changesDoc.TextSelection = changesTRange;
changesDoc.Paste ();
To go at the end of the file again (I think)
var lastPgf = changesDoc.MainFlowInDoc.FirstTextFrameInFlow.LastPgf;
var dividerPgf = changesDoc.NewSeriesPgf (lastPgf);
var TLoc = new TextLoc (dividerPgf, 0);
changesDoc.AddText (TLoc, '_');
}
Hi Mark,
The problem is that the dough does not occur when you think. The dividing line is added at the end of the file, but are not your actions of dough. Actually, I think that maybe a little random where pasta is produced, because this line:
var changesTloc = new TextLoc (firstChgPgf, Constants.FV_OBJ_END_OFFSET);
.. .is does not create a valid text location. You can check this by abandoning the service after:
changesDoc.TextSelection = changesTRange;
.. and look at where's the insertion point. It will probably be everywhere where you left it last, because the call is not valid. I can't tell you exactly why, except that it has something to do with the fact that you are using the last paragraph in the stream. There is something weird to try to define a range of full-paragraph text with the last paragraph. I'm sure it's related to how the last TFP in a stream does not show a mark of FMP, but beyond that, I don't know how to do what you're trying to do with the last paragraph.
Having no knowledge of how do it right, any time I need to do this, I create a paragraph "dummy" at the end of the flow to fill that space strange 'last FMP", then do the work around it. In the end, I just want to remove fake TFP. I don't know if it's a good idea or not, but it's the only way I ever get it to work and it sorts the mirror how you could do this manually in the GUI.
With this, I modified your script as follows, and it seems to work better. Note that I also modified the logic of how to find the last paragraph of the flow by writing a separate function. Your call to the 'FirstTextFrameInFlow' is OK, unless your doc begins to span several pages and/or begins with several empty pages. The function I wrote ensures that you really the last TFP in the stream.
I hope this helps.
Russ
function copyPasteChanges (doc, chgRange) {}
Select the section with changebar and copy it.
doc. TextSelection = chgRange;
doc. Copy();
Prepare for the changes doc and paste there the modified section.
var lastPgf = getLastPgf (changesDoc);
var dummyPgf = changesDoc.NewSeriesPgf (lastPgf);
var changesTloc = new TextLoc (dummyPgf, 0);
var changesTRange = new TextRange (changesTloc, changesTloc);
changesDoc.TextSelection = changesTRange;
changesDoc.Paste ();
To go at the end of the file again (I think)
Don't forget that last TFP is now fake TFP
lastPgf = getLastPgf (changesDoc);
var dividerPgf = changesDoc.NewSeriesPgf (lastPgf.PrevPgfInFlow);
var TLoc = new TextLoc (dividerPgf, 0);
changesDoc.AddText (TLoc, '_');
dummyPgf.Delete ();
}
function getLastPgf (doc)
{
textFrame var is doc. MainFlowInDoc.LastTextFrameInFlow;
var lastPgf = textFrame.LastPgf;
While (! lastPgf.ObjectValid () & textFrame.ObjectValid ())
{
textFrame = textFrame.PrevTextFrameInFlow;
lastPgf = textFrame.LastPgf;
}
Return lastPgf;
}
-
How to get the last day of the week?
HII
I can get the week number of calendar for a given date using
SELECT to_char (to_date('04/04/2011','MM/DD/YYYY'), 'WW') FROM dual
can any body tell me, how to get the last day of the week?
and the answer should be: 04/08/2011(8th april)
Thank you
San
Published by: sandeep9 on April 4, 2011 03:50Perhaps this...
SQL> select trunc(sysdate,'WW')+6 from dual; TRUNC(SYSDATE,'WW')+ -------------------- 08-APR-2011 00:00:00 SQL>
-
Cannot select the last picture
Hello
I have 75 frames in an animation. I have about 6 layers.
I'm putting a stop on the last image statement.
Whenever I open the Actions window it says even if image 1
the playhead is positioned on the last image.
How to place a stop comand on the last image and which layer
should I select?
Thank you
Jim
After having selected the last image, right-click on it and select Insert image. You should now be able to add your stop() command in the last picture.
Maybe you are looking for
-
HPE-500cs: Permutation GTX460 for GTX960 = >; HP Splash screen freeze
Hello guys. So today, I'm really really a lot about GTX 960. I rushed in and bought. Before exchanging I did I have deep cleaning of the pilot. (DDU) Then I swapped the cards. (GTX 460 for the 960) Wattage is sufficient. After pressing the button, th
-
where should I save my files SOUTH?
Hi all I try to call a dialog from a script with this code: Tiara shows the error > cannot find the file 'dlgProgress.SUD '. How can I 'know' DIAdem where to look for the file? (insert the full path instead of "DlgProgress" did not work) Kind regards
-
Hello I have an image that I made and I would like to allow the user to specify a return on investment (a rectangle would be good) to work on. My entry is my 16-bit image (1024 x 768) and I would have output an image that will be the rectangular port
-
Is there somewhere I can go online to check my product key?
I need to replace the hard drive in my Dell Inspiron. I need the product key on the label at the bottom of the laptop, and it is being worn. I think I can read it by taking a picture of him with my digital camera, but I wonder if there's somewhere
-
17 t j000 touchsmart forcing skyrim use nVida video or turn off the graphics card intel
Hi all I just got this new computer and try to make it work with the game Elder Scrolls v Skyrim the game starts and runs ok however by default is of poor quality with video intel detected 4600. Don't want to use the video intel when even, so no