How to get top three count(trap_text)
Hi,
Wrote file afiedt.buf
1 select gasid,count(trap_text) from kr_reported_alerts alerts
2 where exists (select * from kr_reported_alerts where gasid=alerts.gasid)
3* group by gasid
SQL> /
GASID COUNT(TRAP_TEXT)
HUNTER_TEST00001 2
HUNTER_TEST00003 83
HUNTER_TEST00011 4
HUNTER_TEST00024 12918
here i want to get top three count(trap_text) one 12918 and another is 83 and another is 4
Message was edited by:
user517983
Message was edited by:
user517983
Note that the subquery within subquery is completely redundant; for every row in the outer query there is bound to be at least one row (the same row) in the correlated subquery. There could be more, of course (depending on the structure of kr_reported_alerts).
SELECT *
FROM (select gasid,count(trap_text) from kr_reported_alerts alerts
/* NOT NEEDED -- where exists (select * from kr_reported_alerts where gasid=alerts.gasid) */
group by gasid)
WHERE rownum < 4;
The results from this may be different from either RANK or DENSE_RANK. Consider this data set; rows
Gasid Count Rank Dense-Rank Rownum
G1 100 1 1 1
G2 90 2 2 2
G3 90 2 2 3
G4 90 2 2 4
G5 80 5 3 5
G6 80 5 3 6You can see that each will give a different result:
Rank: G1 through G4
Dense Rank: G1 through G5
Rownum: G1 through G3 (in fact the ROWNUM solution could give you any one of G3, G4 or G5 at random)
Regards Nigel
Similar Messages
-
How to get the row Count of a ResultSet
How to get the row Count of a ResultSet
Hi
I'v tried rennie1's way ,but I only get zero,my code is:
rs.executeQuery("select count(*) from t_test");
if (rs.next()) int rowCount=rs.getInt(1);
I also tried barni's way ,but the method rs.last() and rs.beforeFirst() throw a same Exception
I tried another way,the code is:
while rs.next(){
// Do nothing ,just move the cursour to the last row
int rowCount=rs.getRow()
However,the rowCount still equal zero
Any help would be greatly apprecite!
note:
I get connection by DataSource's JNDI name from client, the Server is Weblogic Server 6, the DBMS is Oracle. -
How to get visible row count in JTable ?
I have one table which is added to one scroll pane. For example my table have total 1000 rows, but at a time only 20 rows should be visible to the scroll pane. And I want to scroll the rows and show only 20 at a time.When user scrolls JTable then next time he can view only 1 to 21, then 2 to 22, and so on. I want to know how to get that number which represents the visible row( in this case it is 20).So kindly help me how to get visible row count. Any help regarding this will be appriciated.
Thanks and Regards,
Sheetalhow to get visible row count.First you need to get the viewport used by the scrollpane. Then you can use methods like getViewPosition() and getViewSize() to get information about the current postition of and size of the viewport.
Then you can use the table method getRowAtPoint(). to determine the first and last visible row which can then be used to calculate the visible row count.
When user scrolls JTable then next time he can view only 1 to 21, then 2 to 22, and so onThis is the default behaviour when a "block" scroll is done.
However when you click on the arrow button on the scrollbar it will only scroll a single row. You could override the getScrollableUnitIncrement() method to return the value from the getScrollableBlockIncrement() method.
However the user can still drag the scrollbar manually which would cause a problem. So you would also need to remove the MouseMotionListeners from the scrollbar to prevent this. -
How to get file line count.
Hey guys,
How to get file line count very fast? I am using BufferedReader to readLine() and count. But when dealing with big file, say several GB size, this process will be very time consuming.
Is there any other methods?
Thanks in advace!What I'd do is you create an infofetcher, register a listener, implement gotMore() and have that scan for '\n'
Some might suggest getting rid of the listener/sender pattern or use multiple threads to make ii faster. This might help a little, but only if your I/O is super-duper speedy.
you are welcome to use and modify this code, but please don't change the package or take credit for it as your own work.
InfoFetcher.java
============
package tjacobs.io;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Iterator;
* InfoFetcher is a generic way to read data from an input stream (file, socket, etc)
* InfoFetcher can be set up with a thread so that it reads from an input stream
* and report to registered listeners as it gets
* more information. This vastly simplifies the process of always re-writing
* the same code for reading from an input stream.
* <p>
* I use this all over
public class InfoFetcher implements Runnable {
public byte[] buf;
public InputStream in;
public int waitTime;
private ArrayList mListeners;
public int got = 0;
protected boolean mClearBufferFlag = false;
public InfoFetcher(InputStream in, byte[] buf, int waitTime) {
this.buf = buf;
this.in = in;
this.waitTime = waitTime;
public void addInputStreamListener(InputStreamListener fll) {
if (mListeners == null) {
mListeners = new ArrayList(2);
if (!mListeners.contains(fll)) {
mListeners.add(fll);
public void removeInputStreamListener(InputStreamListener fll) {
if (mListeners == null) {
return;
mListeners.remove(fll);
public byte[] readCompletely() {
run();
return buf;
public int got() {
return got;
public void run() {
if (waitTime > 0) {
TimeOut to = new TimeOut(waitTime);
Thread t = new Thread(to);
t.start();
int b;
try {
while ((b = in.read()) != -1) {
if (got + 1 > buf.length) {
buf = IOUtils.expandBuf(buf);
int start = got;
buf[got++] = (byte) b;
int available = in.available();
//System.out.println("got = " + got + " available = " + available + " buf.length = " + buf.length);
if (got + available > buf.length) {
buf = IOUtils.expandBuf(buf, Math.max(got + available, buf.length * 2));
got += in.read(buf, got, available);
signalListeners(false, start);
if (mClearBufferFlag) {
mClearBufferFlag = false;
got = 0;
} catch (IOException iox) {
throw new PartialReadException(got, buf.length);
} finally {
buf = IOUtils.trimBuf(buf, got);
signalListeners(true);
private void setClearBufferFlag(boolean status) {
mClearBufferFlag = status;
public void clearBuffer() {
setClearBufferFlag(true);
private void signalListeners(boolean over) {
signalListeners (over, 0);
private void signalListeners(boolean over, int start) {
if (mListeners != null) {
Iterator i = mListeners.iterator();
InputStreamEvent ev = new InputStreamEvent(got, buf, start);
//System.out.println("got: " + got + " buf = " + new String(buf, 0, 20));
while (i.hasNext()) {
InputStreamListener fll = (InputStreamListener) i.next();
if (over) {
fll.gotAll(ev);
} else {
fll.gotMore(ev);
InputStreamListener.java
====================
package tjacobs.io;
public interface InputStreamListener {
* the new data retrieved is in the byte array from <i>start</i> to <i>totalBytesRetrieved</i> in the buffer
public void gotMore(InputStreamEvent ev);
* reading has finished. The entire contents read from the stream in
* in the buffer
public void gotAll(InputStreamEvent ev);
InputStreamEvent
===============
package tjacobs.io;
* The InputStreamEvent fired from the InfoFetcher
* the new data retrieved is from <i>start</i> to <i>totalBytesRetrieved</i> in the buffer
public class InputStreamEvent {
public int totalBytesRetrieved;
public int start;
public byte buffer[];
public InputStreamEvent (int bytes, byte buf[]) {
this(bytes, buf, 0);
public InputStreamEvent (int bytes, byte buf[], int start) {
totalBytesRetrieved = bytes;
buffer = buf;
this.start = start;
public int getBytesRetrieved() {
return totalBytesRetrieved;
public int getStart() {
return start;
public byte[] getBytes() {
return buffer;
ParialReadException
=================
package tjacobs.io;
public class PartialReadException extends RuntimeException {
public PartialReadException(int got, int total) {
super("Got " + got + " of " + total + " bytes");
} -
How to get succesfullt loaded count in forall
hi,
plz tell me how to get succefuly loaded count into a table if i m using bulk collect & forall .Check out the documentation:
Counting Rows Affected by FORALL with the %BULK_ROWCOUNT Attribute
The cursor attributes SQL%FOUND, SQL%ISOPEN, SQL%NOTFOUND, and SQL%ROWCOUNT, return useful information about the most recently executed DML statement. For additional description of cursor attributes, see "Implicit Cursors".The SQL cursor has one composite attribute, %BULK_ROWCOUNT, for use with the FORALL statement. This attribute works like an associative array: SQL%BULK_ROWCOUNT(i) stores the number of rows processed by the ith execution of an INSERT, UPDATE or DELETE statement. -
How to get the column count at the bottom of the column
Hi Friends,
How to get the column count at the bottom of the column
Thanks
RajYou mean row count? Add another column, click on the fx button and type RCOUNT(1).
If you want just the total you can make it MAX(RCOUNT(1)), hide this column and then add a Narrative View after your report and enter "Total Number of Records: @n" where "n" represents what order your column is from the left side. -
How to get top 10 employees in BEx Report
Hi all,
I am trying to get top 10 employees who have worked over 50 hrs of overtime in any pay period i choose in query.
How do i get it ??
right now my report gives me total of over 50hrs overtime in all chosen pay period employees list.
Any suggestions ??
Thank You,
KSmithCAN SOMEONE PLEASE HELP ME SOLVE THIS PROBLEM ??
Hi all,
The problem I have is even though i tried condition for top 10 employees who worked more than 50 hrs.
My report right now shows all employees overtime under "OT" key figure for each pay period. --> I just want to show employees and overtime which is > 50 for each different pay period
The condition works only if i display just one pay period...and user dont want it that way. they want to get more than one pay period displayed on the report and should have list of employees who work more than 50 hrs over time. HOW DO I GET THAT ??
Also there is another key figure count meaning if out of those chosen pay periods there are 3 periods when an employee worked more than 50 hrs of over time then it should show "3". if there 2 pay periods when employee work more than 50 hrs count should display 2 ---> right now i am not able to get that also.
Please can some one suggest something ??
Thank You,
KSmith
Edited by: Keral Smith on Jul 25, 2008 2:49 PM
Edited by: Keral Smith on Jul 25, 2008 3:08 PM -
File Adapter - how to get the file count from a folder
Hi All,
I have a requirement that have to poll a directory when the file count is reached to number N (ex:number of files avilable in folder is 5) otherwise it should wait and not pick any of the files. Is it possible to get the file count from a folder using file adapter ?? otherwise please suggest me an approach to achieve this requirement.
Thanks,
JJHi Sarath,
Thank you for your reply.
Go with the list files operation of file adapter it will gives you the number of files in the specified folder as you given. . - this step is already done.
When the number of files reaches your count startup your webservice that which can polls the files. . . - how can i acheive this?? Have to poll the directory and process the number files - please let me know, what could be added to the webservice which is being invoked after cheking file count from parent process.
The reason for the above question is - we cannot use ReadFile operation in second webservice because it will be automatically triggered when the file is avilable. Also SyncRead operation supports reading one file in b/w bpel process. Kindly explain me the implementation steps.
Thanks,
JJ -
How to get updated by count value in database ?
hi all,
I created jsp page iin which insert,update,delete , query and queryall Functionalities are working...
I need following,
whenever i update a record i should get updated by, updated time and updated count.. to be stored in database...
i achieved to store updated by and updated time...
please help me how to get updated count:
when ever a record is updated for first time updated count=1,
for second time it should be 2 for third time it should be 3 and so onnnn
please help me how to write this kind of function and kind of code help will be appriciated....if you want "number of updates" performed on each row to be persistive, you should have designed the schema with an extra field which keeps number of updates performed.
to generic solution sql statement should have been written like
INSERT INTO table (a,b,c,update_count) VALUES (1,2,3,4)
ON DUPLICATE KEY UPDATE update_count=update_count+1;in this case even a insert statement will work, you wouldn't had to write another update statement.
or if u want to use update statement only
have an extra column "update_count" do "update_count=update_count+1" on each update statement, set initial default value to 0;
and if u want to know how many rows have been updated
as BalusC wrote
BalusC wrote:
PreparedStatement#executeUpdate() returns an int which represents the amount of affected rows. -
How to get top 10 records for each option in table prompt?
Hi,
I have created one report in which my requirement is to get top 10 highest salaries for each departments. I have created one table prompt which contains the names of all departments. On the salary column I have applied one filter i.e. TOP 10. Currently I am having 3 departments. I want to show the top 10 salaries for each department, but I am getting top 3 from first, 4 from second and 3 from third.They are calculating top 10 salaries based on all departments, not on individual department. How can I get top 10 salaries for each department?Hi,
Use TopN function in your column formula.
Ex: TOPN("Sales ,5 BY department)
Thanks,
Satya -
How to get the FILE COUNT from File directory
Hello,
i have to develop a scenario like, get the file count from source file directory and validate whether the file count is 5 or not. if 5 files exist i need to process those 5 files to DB tables. if file count is not equal to 5 then i need to send a mail to customer that files are missed at source directory. (subject as files were missed at source directory and in content i need to display the file names exist at source file directory. So that missed file will be generated by the customer based on this mail).
Could you please let me know how to get the count of files from source file directory. if it is possible only with UDF please provide the Java code
Best Regards,
SARANDo these files have some fixed names?
Can you try to use the option Advanced Selection For Source File to make XI pick all 5 files in one shot?
Check this blog on the same -
/people/mickael.huchet/blog/2006/09/18/xipi-how-to-exclude-files-in-a-sender-file-adapter
If this is not a option - BPM sounds the only possible way.
Regards,
Bhavesh -
How to get the page count in XML Publisher Report
Hi Team,
I am generating one xml report. I want to get the total Page count in XML publisher report. This page count is depends on the input Parameters at runtime. How to get this total page count on the runtime dynamically.
Best Regards
Srithere is some seeded variable available please read xml publisher developer user guide
-
How to get TOP 5 results in version 7.3.4?
Hello,
I have try to use subquery in a query to get the top 5 result in Oracle version 7.3.4, it seems like not working. Can you please tell me how to get the TOP 5 results with Oracle 7.3.4??
For example,
REJECT CATEGORY QUANTITY
AA 100
BB 5
CC 20
DD 73
EE 88
FF 76
GG 43
HH 99
So i want to get the result as AA, HH, EE, FF, DD.
Thanks.I don't have that version available to me and I forgot if rownum was already available. See if this works:
select * from (
select category, quantity, rownum rn
from reject
order by quantity desc)
where rn <= 5;
Note that this is not the same as the TOP posibilities in 9i, but you example seems to suggest this should be enough.
Also note that on big tables, this query is performing porely because Oracle first needs to sort all records.
L. -
Using Powershell cmdlet i get all the details..But i want to get these Details by using EWS Managed Api.Is It Possible to do???
Powershell Cmdlet,
Get-MailboxStatistics -Identity Username, Using this cmdlets all the details will get displayed.
DeletedItemCount:5 //Here how this count comes.In My OutlookWebApp the deleteditems folder contains 13 items in it..But the count shows only 5.
TotalDeletedItemSize:5.465 Kb//Even this value too does not match with DeletedItems Folder size in owa.
AssociatedItemCount:12
LastLogOnTime:11/11/11 12:43PM
LastLogOff Time:11/11/11 2:43PM
In EWS,
By Looping through all folders i can get the total item count and total item size.Even i can get deleteditems count .But that value does not match With the powershell value.Even the TotalDeletedItemSize
Doesnt match.
Using EWS Managed Api ,Looping through folders i can get ItemCount,TotalitemSize,(DeletedItems,TotalDeleteditemSize(These TwoValues Does not match with values comes from powershell))
Now how to get the Associated item count and lastlogoff and logon time using EWS managed Api.Is it Possible???
And even y the deleteditems count and size values varies between EWS and powershell.What happens if you execute the below code?
Get-MailboxFolderStatistics [email protected] | where {$_.FolderPath -like "/Deleted Items"}
Refer this blog. You may get some dice
http://exchangepedia.com/blog/2008/09/configuring-deleted-item-retention.html
Regards Chen V [MCTS SharePoint 2010] -
How to get top 3 record from aggregated column
Hello,
i have a simple query which return all student in class with total marks. now i want to select top 3 student whose score is maximum. simple top three position. how can i use rank function here? or any other way to do that
select st.sti_roll_no ,st.sti_name , sum(rd.rd_obt_marks) as mycol from rd_result_detail rd , rm_result_master rm, sti_student_info st
where rm.rm_result_id = rd.rd_result_id
and st.sti_roll_no= rd.rd_student_id
--and rd.rd_student_id = 'MBP10293'
and rm.rm_semester = 3
and rm_session = 2009
and rm_batch= 3
and rm.rm_exam_type ='FINAL TERM'
and rm.rm_class_id = 'MBA'
group by st.sti_name, st.sti_roll_no
order by st.sti_roll_no;Not sure!!!!!!!!!!!!!
with t as
(select st.sti_roll_no ,st.sti_name , sum(rd.rd_obt_marks) as mycol from rd_result_detail rd , rm_result_master rm, sti_student_info st
where rm.rm_result_id = rd.rd_result_id
and st.sti_roll_no= rd.rd_student_id
--and rd.rd_student_id = 'MBP10293'
and rm.rm_semester = 3
and rm_session = 2009
and rm_batch= 3
and rm.rm_exam_type ='FINAL TERM'
and rm.rm_class_id = 'MBA'
group by st.sti_name, st.sti_roll_no
order by st.sti_roll_no)
select sti_roll_no ,sti_name,mycol,dense_rank()over(order by mycol desc) rnk
from t
--where rnk<=3
SQL> ed
Wrote file afiedt.buf
1 select e.* from (select empno,ename,sal,dense_rank()over(order by sal desc) rnk
2* from emp)e where rnk<=3
SQL> /
EMPNO ENAME SAL RNK
7839 KING 5000 1
7788 SCOTT 3000 2
7902 FORD 3000 2
7566 JONES 2975 3
Maybe you are looking for
-
Start routine error - infosource 2LIS_13_VDITM
Hello, During the activation of the standard InfoCube 0SD_C03 (Sales: Overview), I have encountered a problem in a transformation between the infosource 2LIS_13_VDITM and the afrementioned Cube (this transformation has been transferred during the act
-
Mark Up Price in the Pricing Procedure
Hi I want to add 45 % of my Moving avg price automatically , when i select my pricing procedure.Say if the price is 100 $, i want to select the pricing condition and expecting the system to assign 145 % automatically.How to do in the Pricing Procedu
-
Ask about how to append text on next line
I'm writing lingo about log file. For example, i would like to write like this when a new entry is appended: etc 3/29/2007 8:34 PM etc2 3/29/2007 8:34 PM Here is the lingo: on mouseUp if objectP(myFile) then set myFile = 0 -- Delete the instance if i
-
Embedded LDAP password issue in Weblogic 7
Is this normal? Seems odd to me... After installing weblogic 7 using the wizard and giving a new password other than "weblogic" for the "weblogic" user, and after using boot.properties to get an encrypted version, the embedded LDAP servers for both a
-
How can i uninstall this application??