How to use the rownum to get only 5 records?
Hello Folks,
I have this queury which pulls in the CLient,EventStatus along with the Events for each user. I just want to condense the data so that each user has not more than 5 events.
select c.client_code "Client Code",
c.client_name "Client Name",
e.event_id "Event ID", -- there can be 5 or more events per user
e.event_status_code "Event Status",
al.end_user_id "User ID",
eu.user_real_name "User Name" -- user
al.activity_date "Activity Date",
al.activity_log_type_code "Activity Type",
al.activity_party "Activity Party",
al.activity_subject "Activity Subject",
al.activity_source "Activity Source",
al.activity_text "Activity Text",
e.created_date "Event Created Date"
from budget b, activity_log al, client c, event e, end_user eu, profile_lookup pl, event_case ec
where b.event_case_id = al.event_case_id
and e.event_id = ec.event_id
and al.event_case_id = ec.event_case_id
and e.client_id = c.client_id
and al.end_user_id = eu.end_user_id
and eu.profile_id = pl.profile_id
and al.activity_source <> 'SYS'
and al.activity_log_type_code not in ('MAIL PRINT')
and (
(al.activity_log_type_code <> 'PROJECTION')
or
(al.activity_log_type_code = 'PROJECTION'and b.budget_status <> 'APPROVED')
and pl.profile_name like 'NEGOTIATOR%'
and al.activity_date >= to_date('20101123 000000', 'YYYYMMDD HH24MISS')
and al.activity_date <= to_date('20101123 235959', 'YYYYMMDD HH24MISS')
sample data:
647 IL-FEP BLUE CROSS BLUE SHIELD OF ILLINOIS 219678 OPEN 867 AARON HILTON 11/23/2010 2:12:44 PM FAX SENT SAUL FERRIS Confirmation of Settlement Amo MAIL "Fax of Confirmation of Settlement Amount sent to SAUL FERRIS FAILED.
Details :
" 7/11/2009 7:26:45 PMEdited by: user11961230 on Nov 24, 2010 8:11 AM
Edited by: user11961230 on Nov 24, 2010 8:11 AM
Edited by: user11961230 on Nov 24, 2010 8:12 AM
Edited by: user11961230 on Nov 24, 2010 8:18 AM
Edited by: user11961230 on Nov 24, 2010 8:19 AM
user11961230 wrote:
ORA-00923: FROM Keyword not found where expected
Issue is your original query had not equal condition as <> in two places Since <> has special meaning (empty tag) in HTML, they disappeared. I fixed it in one spot with using != instead but missed the othe. Anyway:
select "Client Code",
"Client Name",
"Event ID",
"Event Status",
"User ID",
"User Name"
"Activity Date",
"Activity Type",
"Activity Party",
"Activity Subject",
"Activity Source",
"Activity Text",
"Event Created Date"
from (
select c.client_code "Client Code",
c.client_name "Client Name",
e.event_id "Event ID",
e.event_status_code "Event Status",
al.end_user_id "User ID",
eu.user_real_name "User Name"
al.activity_date "Activity Date",
al.activity_log_type_code "Activity Type",
al.activity_party "Activity Party",
al.activity_subject "Activity Subject",
al.activity_source "Activity Source",
al.activity_text "Activity Text",
e.created_date "Event Created Date",
row_number() over(partition by al.end_user_id order by e.event_id) rn
from budget b,
activity_log al,
client c,
event e,
end_user eu,
profile_lookup pl,
event_case ec
where b.event_case_id = al.event_case_id
and e.event_id = ec.event_id
and al.event_case_id = ec.event_case_id
and e.client_id = c.client_id
and al.end_user_id = eu.end_user_id
and eu.profile_id = pl.profile_id
and al.activity_source != 'SYS'
and al.activity_log_type_code not in ('MAIL PRINT')
and (
(al.activity_log_type_code 'PROJECTION')
or
(al.activity_log_type_code = 'PROJECTION'and b.budget_status != 'APPROVED')
and pl.profile_name like 'NEGOTIATOR%'
and al.activity_date >= to_date('20101123 000000', 'YYYYMMDD HH24MISS')
and al.activity_date <= to_date('20101123 235959', 'YYYYMMDD HH24MISS')
where rn <= 5
/ SY.
Similar Messages
-
How to use the forums and get (helpful) help!
Please, I beg you, read the Javadoc on the class you are asking about:
http://java.sun.com/j2se/1.4/docs/api/index.html
Have you looked for an answer in Suns training documentation, tutorials and Java specification?
http://developer.java.sun.com/developer/infodocs/
Post your code so that it is readable:
http://forum.java.sun.com/faq.jsp#messageformat
Of course, is everyone followed these rules (including me) these forums would probably be a very lonely place ;)You either use single quotes in the SQL string, or (my preferred method) use a Prepared Statement
String sql = "select count(cc.id) from customers c, creditcards cc where c.cc_id = '" + ccID+ "' ";
// or better IMO
sql = "select count(cc.id) from customers c, creditcards cc where c.cc_id = ?");
PreparedStatement pstmt = con.prepareStatement(sql);
sql.setString(1, ccID);The prepared statement protects you agains SQL injection attacks, and any values that would need escaping in SQL. What would happen if someone entered a single quote in the ccID field? -
How to use the Function module 'BAPI_APPRAISAL_GETDETAIL'
hello friends,
I have to create the report which displays appraisee name, appraiser name,reviewer name and result.Using BAPI_APPRAISAL_GETDETAIL we can get the above all.But i don't know how to use the above function module.If anyone have used in their program could you please send me or anyone have idea how to do that Please help.It is very Urgent Help me.
Thanks in advance,
Regards,
Ashok.Hi,
I do not hae the code but i can tell you how you use the FM and get the required data, please follow the below mentioned steps:
1) In this Bapi you need to pass the Plan verison and Object Id data in the BAPI Import parameters and while passing the these values need to decalra the data variables same (of use the same reference fields as they are in Bapi import fields)as they are Bapi importing data fields.
2) decalre the Internal Table structure as they are in the Export and Table parameters.
3) Assign the decalred Import and Tables structures to the BAPI FM.
4) once the Bapi is run with the Import parameters data the Apprisal data and Apprisee data will returened in the import and table structures and also return value wll be imported.
5) now using the Structures which are in Import and Table decalrations in the FM you can retrieve the data by reading them.
Do let me know if you need any more details in this regard.
Raghotham Reddy.
If you find this is the right solution then allocate reward point. -
Where do I find a tutorial about how to use the new iTunes? I have version 11.1.3 (8). I looked on the Apple web site but only found info extolling the virtues of iTunes, not how to use it.
Use it the same way as previously.
ctrl B shows the menus.
ctrl S shows the sidebar.
What else do you need help with? -
Question to all the pros..I'm looking to purchase an iPad 4g second hand. Once the "seller" resets the iPad for me to use, do I have to get it re-activated or purchase a contract/service plan if I ONLY ever plan to use the iPad for Wifi Only???
No you don't need a service plan to use wifi. Take special precautions to make sure the seller is the owner. Be sure all their information has been removed properly. If it were me I wouldn't give the person the money until the iPad is registered in my name. I've read too many horror stories of people buying iPads they'll never be able to use because someone else's ID was still on it.
-
My baby must of hit a combination of keys while no one was looking and i don`t have use of some of my keys any more it`s like my function setting on the key board is stuck on. It only does it while in firefox though my keyboard works normally otherwise
In addition to the above:
Windows remembers the keyboard layout setting per application and you may have changed the keyboard layout by accident via a keyboard shortcut.
See:
* http://support.microsoft.com/kb/306993 - HOW TO: Use the Language Bar in Windows XP
The default keys to rotate the layout is a combination (Ctrl+Shift or Alt+Shift) that can easily be used in Firefox to activate a menu item.<br />
To avoid an unintentional switch, assign a specific key sequence (Alt/Ctrl+Shift+number) to select keyboard layouts and remove the key combination to rotate layouts (Alt+Shift or Ctrl+Shift)
* Control Panel > Regional and Language Options > Keyboards and Languages > Change keyboards > Advanced key settings > Change key sequence
*http://support.microsoft.com/kb/258824 - How to change your keyboard layout -
After upgrading my I-Pad I now have to use a password everytime I open it. How do I delete using the password to get into my i-pad?
Thank you,
out of the five helps -
your's was the most explicite
and it worked.
Thank you so much,
Susan -
I have two email accounts. However, the iPad automatically uses the account that I only want to use for business. How can I change the account from which mail is sent and received?
You are most welcome
-
Whenever I send a email from iPad mail app with an attachment from pages or numbers, the receiver is getting only attachment in the email. They are getting the email content. How to troubleshoot this issue.
Someone is probably sending spam with your address forged on the To: line. Could be one of your old contacts with a Windows machine has a virus that's doing it. It's also possible your e-mail account has been hacked, though I'd think such a hacker would be a bit more purposeful.
For more information, see:
http://www.reedcorner.net/guides/macvirus/is_it_malware.php#spam
* Disclaimer: links to my pages may give me compensation, and should not be taken as endorsement of my services by Apple. -
JNI - How to use the error reporting mechanism?
I've developed a C++ DLL which is loaded from a commercial Win32 application (not written by me) as a plug-in for external calculations. On its initialization the C++ DLL launches the Java VM via the JNI invocation interface. When the DLL functions are called by the application, they forward the calls to Java objects inside the Java VM, again via JNI invocation interface.
This works well, but I have encountered a weird error.
From Java I open a JFrame containing a JTextArea as small console for debug output messages. If I turn output to this debug console off (my printToConsole routine checks whether a boolean flag is set), the string concatenation operator may lead to a crash of the Java VM.
For example, if in one of the Java functions called from the
DLL via JNI invocation interface the following is the first statement,
it leads to a crash of the Java VM and the application that loaded the C++ proxy DLL.
String test=""+Math.random(); // String test not used later
Interestingly, if I comment this statement out, the Java code works fine WITHOUT any crash. I've already thought about potential races and synchronization issues in my code, but I don't see where this is the case. And the string concatenation error fails as well, if I insert sleep() statements in front of it and at other places in the code. However, if I turn on log messages printed to my JFrame debug console (containing a JTextArea), the String concatenation works without problems.
So maybe the JNI interface has a bug and affects the Java VM; I don't see where my JNI code is wrong.
One problem is that I do not get any stdout output, as the C++ proxy DLL is loaded by the Windows application, even if I start the Windows application from the DOS command line (under Windows).
Does anyone know how to use the error reporting mechanism?
http://java.sun.com/j2se/1.4.2/docs/guide/vm/error-handling.html
Is it possible that the JVM, when it crashes, writes debug information about the crash into a file instead of stdout/stderr?
My C++ proxy DLL was compiled in debug mode, but the commercial application (which loaded the DLL) is very likely not.
I do not know hot to find the reason why the String concatenation fails inside the Java function called from the C++ DLL via JNI.Yes, I've initially thought about errors in the C++ code too. But the C++ code is actually very simple and short. It doesn't allocate anything on the C++ side. It allocates a couple of ByteBuffers inside the Java VM however via JNI invocation interface calls of env->NewDirectByteBuffer(). The native memory regions accessed via the ByteBuffers are allocated not by my own C++ code, but by the program that calls my DLL (the program is Metastock).
The interesting thing is that everything works fine if output to my debug console is enabled, which means that in the Java print routine getConsoleLoggingState() returns true and text is appended to the jTextArea.
static synchronized void print(String str)
{ MetaStockMonitor mMon=getInstance();
if ( mMon.getFileLoggingState() && mMon.logFileWriter!=null) {
mMon.logFileWriter.print(str);
mMon.logFileWriter.flush();
if ( mMon.getConsoleLoggingState() ) {
mMon.jTextArea1.append(str);
Only if output to the JTextArea is turned off (ie. getConsoleLoggingState()==false), the crash happens when the FIRST statement in the Java routine called via JNI invocation interface is a (useless) String concatenation operation, as described above.
String test=""+Math.random(); // String test not used later
Moreover, the crash happens BEFORE the allocated ByteBuffer objects are accessed in the Java code. But again, if console output is turned on, it works stable. If console output is turned off, it works when the (useless) String concatenation operation is removed in the Java routine called from C++.
I've already thought about potential races (regarding multiple threads), but this can be ruled out in my case. It almost appears as if the JVM can have problems when called by the invocation interface (I tested it with Java 1.4.2 b28).
All the calls between C++ and Java go ALWAYS in the direction from C++ code to Java. Unfortunately, there is no special JRE version with extensive logging capabilities to facilitate debugging. And the problem is not easily reproducible either.
JNIEnv* JNI_GetEnv()
JNIEnv *env;
cached_jvm->AttachCurrentThread((void**)&env,NULL);
fprintf(logfile,"env=%i\n",env);
fflush(logfile);
return env;
// function called by Metastock's MSX plug-in interface
BOOL __stdcall createIndEngine (const MSXDataRec *a_psDataRec,
const MSXDataInfoRecArgsArray *a_psDataInfoArgs,
const MSXNumericArgsArray *a_psNumericArgs,
const MSXStringArgsArray *a_psStringArgs,
const MSXCustomArgsArray *a_psCustomArgs,
MSXResultRec *a_psResultRec)
a_psResultRec->psResultArray->iFirstValid=0;
a_psResultRec->psResultArray->iLastValid=-1;
jthrowable ex;
jmethodID mid;
JNIEnv* env=JNI_GetEnv();
jobject chart=getChart(env, a_psDataRec);
if ( chart==NULL) {
return MSX_ERROR;
jobject getChart (JNIEnv* env, const MSXDataRec *a_psDataRec)
jthrowable ex;
jmethodID mid;
int closeFirstValid, closeLastValid;
closeFirstValid=a_psDataRec->sClose.iFirstValid;
closeLastValid=a_psDataRec->sClose.iLastValid;
long firstDate, firstTime;
if (closeFirstValid>=1 && closeFirstValid<=closeLastValid) {
firstDate = a_psDataRec->psDate[closeFirstValid].lDate;
firstTime = a_psDataRec->psDate[closeFirstValid].lTime;
} else {
firstDate=0;
firstTime=0;
jclass chartFactoryClass = env->FindClass("wschwendt/metastock/msx/ChartFactory");
if (ex= env->ExceptionOccurred() ) {
env->ExceptionDescribe();
env->ExceptionClear();
sprintf(sbuf, "DLL: Cannot find class ChartFactory\n");
printSBufViaJava(sbuf);
return NULL;
mid = env->GetStaticMethodID(chartFactoryClass, "getInstance", "()Lwschwendt/metastock/msx/ChartFactory;");
if (ex= env->ExceptionOccurred() ) {
env->ExceptionDescribe();
env->ExceptionClear();
sprintf(sbuf, "DLL: Cannot find method ID for ChartFactory.getInstance()\n");
printSBufViaJava(sbuf);
return NULL;
jobject chartFactory=env->CallStaticObjectMethod(chartFactoryClass, mid);
if (ex= env->ExceptionOccurred() ) {
env->ExceptionDescribe();
env->ExceptionClear();
sprintf(sbuf, "DLL: Exception while calling ChartFactory.getInstance()");
printSBufViaJava(sbuf);
return NULL;
mid = env->GetMethodID(chartFactoryClass, "getChartID", "(Ljava/nio/ByteBuffer;Ljava/nio/ByteBuffer;Ljava/nio/ByteBuffer;Ljava/nio/ByteBuffer;IIIIIII)F");
if (ex= env->ExceptionOccurred() ) {
env->ExceptionDescribe();
env->ExceptionClear();
sprintf(sbuf, "DLL: Cannot find method ID for ChartFactory.getChartID()\n");
printSBufViaJava(sbuf);
return NULL;
jobject symbolBuf=env->NewDirectByteBuffer(a_psDataRec->pszSymbol, strlen(a_psDataRec->pszSymbol) );
if (ex= env->ExceptionOccurred() ) {
env->ExceptionDescribe();
env->ExceptionClear();
sprintf(sbuf, "DLL: Cannot allocate symbolBuf\n");
printSBufViaJava(sbuf);
return NULL;
jobject securityNameBuf=env->NewDirectByteBuffer(a_psDataRec->pszSecurityName, strlen(a_psDataRec->pszSecurityName) );
if (ex= env->ExceptionOccurred() ) {
env->ExceptionDescribe();
env->ExceptionClear();
sprintf(sbuf, "DLL: Cannot allocate securityNameBuf\n");
printSBufViaJava(sbuf);
return NULL;
jobject securityPathBuf=env->NewDirectByteBuffer(a_psDataRec->pszSecurityPath, strlen(a_psDataRec->pszSecurityPath) );
if (ex= env->ExceptionOccurred() ) {
env->ExceptionDescribe();
env->ExceptionClear();
sprintf(sbuf, "DLL: Cannot allocate securityPathBuf\n");
printSBufViaJava(sbuf);
return NULL;
jobject securityOnlineSourceBuf=env->NewDirectByteBuffer(a_psDataRec->pszOnlineSource, strlen(a_psDataRec->pszOnlineSource) );
if (ex= env->ExceptionOccurred() ) {
env->ExceptionDescribe();
env->ExceptionClear();
sprintf(sbuf, "DLL: Cannot allocate onlineSourceBuf\n");
printSBufViaJava(sbuf);
return NULL;
// Java Function call leads to crash, if console output is turned off and
// the first statement in the Java routine is a (useless) string concatenation.
// Otherwise it works stable.
jfloat chartID=env->CallFloatMethod(chartFactory, mid, securityNameBuf, symbolBuf,
securityPathBuf, securityOnlineSourceBuf, (jint)(a_psDataRec->iPeriod),
(jint)(a_psDataRec->iInterval), (jint)(a_psDataRec->iStartTime),
(jint)(a_psDataRec->iEndTime), (jint)(a_psDataRec->iSymbolType),
(jint)firstDate, (jint)firstTime );
if (ex= env->ExceptionOccurred() ) {
env->ExceptionDescribe();
env->ExceptionClear();
sprintf(sbuf, "DLL: Exception while calling ChartFactory.getChartID()");
printSBufViaJava(sbuf);
return NULL; -
How to use the "out" parameter in idl
hello.idl:
module HelloApp
interface Hello
string sayHello();
void getPass(in string name,out string pass);
HelloServer:
public class HelloServer
class HelloServant extends _HelloImplBase
public void getPass(String name,org.omg.CORBA.StringHolder pass)
System.out.println("Server pass = " + pass);
if (name.equals("lxh"))
pass = new org.omg.CORBA.StringHolder("1234");
if (name.equals("cbj"))
pass = new org.omg.CORBA.StringHolder("5678");
HelloClient:
public class HelloClient
public static void main(String args[])
try{
org.omg.CORBA.StringHolder Pass = null;
if (args.length == 1)
System.out.println("Client pass = " + args[0]);
helloRef.getPass(args[0],Pass);
System.out.println(Pass);
} catch(Exception e) {
When I run client main method with parameter "lxh",I will get a error says the getPass() parameter which has given is wrong.
How to use the out parameter in client?Does this error only occurs if you pass "lxh" or always?
Did you try passing a StringHolder Object rather than a NULL Object?
Perhaps you can post the error message!? -
How to use the "identify" feature in new 6.3.1 airport utility?
how to use the "identify" feature in new 6.3.1 airport utility?
so you can find the basestations in larger networks?There is a workaround, which is to use Airport Utility 5.6.
I can confirm that 5.6 will run on 10.8.4 Mountain Lion, it will recognize the new 2013 Airport Extreme Base Station (A1521) running firmware 7.7.1, and it will give you access to view the device's Log & Statistics, DHCP Clients, and Profiles.
Four caveats:
1) The easiest way to install it is to download the app itself, not an installer or through the App Store. There is a page here where you can download the app: http://coreyjmahler.com/2013/03/08/airport-utility-5-6-on-os-x-v10-8-mountain-li on/ This way, you still have both versions, Airport Utility 6.x.x and 5.6.
2) When you launch 5.6, you'll get a message saying a newer version is available and asking if you want to update. Click Cancel to proceed into the utility.
3) When you click the Manual Setup button in 5.6, you'll get a warning dialog that "This version of AirPort Utility doesn't support this AirPort wireless device and might improperly configure the device if you continue to use it. Check www.apple.com/support/airport for the latest version of AirPort Utility." You can click Continue to get into the utility without issue.
4) You should probably only use 5.6 to view the additional status details. I have not tried to modify and save any AEBS settings using 5.6. There are other discussions here in the forums indicating that attempting to save settings via 5.6 that are no longer available in 6.3.1 will not actually save the settings to the AEBS even if both utilities indicate that the settings are changed. See https://discussions.apple.com/message/22677993#22677993
So, even though you can't use it to modify settings no longer available in Airport Utility 6.3.1, using Airport Utility 5.6 to view DHCP clients, Logs and Statistics is very useful for troubleshooting network issues.
PS - There are two ways to get to the DHCP Clients list, neither of which is obvious The first is to go to the Airport pane -> Summary tab and click on the "Wireless Clients:" label in the Summary display. All of the labels from "Wireless Mode:" down on the Summary display operate as links to view/edit the corresponding info/settings, which is also not obvious at first glance. Also not obvious, clicking on "Wireless Clients:" actually brings up a new pane with three tabs: Logs, Wireless Clients, and DHCP Clients. You can also get to the same pane by going to the Advanced pane and clicking on the Logs and Statistics button.
I hope this is helpful information. Took me a while to find out how to do this. -
How to use where clause with get statement in LDB programs
Hi All,
I am using logical databse in my report program.I am not getting how to use the where clause in the get statement is it possible to use?or if not possible only option is we should filter it after get statment is right?Can you please some body throw some idea on this?
Regards
MaheshHi,
Reffer these links
http://help.sap.com/saphelp_nw04/helpdata/en/9f/db9bfa35c111d1829f0000e829fbfe/content.htm
http://help.sap.com/saphelp_nw04/helpdata/en/9f/db9b5e35c111d1829f0000e829fbfe/frameset.htm
http://help.sap.com/saphelp_nw04/helpdata/en/c6/8a15381b80436ce10000009b38f8cf/frameset.htm
/people/srivijaya.gutala/blog/2007/03/05/why-not-logical-databases
reward if helpful
Thanks,
Suma. -
Uses the library to get UTL_FILE to read a excel file in PL SQL?
Good day.
Someone can give me some code that uses the library to get UTL_FILE to read a excel file in PL SQL?
I intend to use this library because I want to run a script on my machine to treat an excel file without having to make changes on the server.
Thank you.163d6dc5-fa66-4eb1-b7d5-653dea63bbc8 wrote:
Good day.
Someone can give me some code that uses the library to get UTL_FILE to read a excel file in PL SQL?
I intend to use this library because I want to run a script on my machine to treat an excel file without having to make changes on the server.
Thank you.
Ranit's links are useful, you should read them.
Also check out the FAQ on this forum:Re: 5. How do I read or write an Excel file?
UTL_FILE is not the best choice for reading data from Excel files.
It also will not be able to read an Excel file located on your client computer. As with any PL/SQL code on the database, it can only access things that the server itself can see, so that doesn't include hacking across the network, bypassing network security, and hacking into the client computers operating system to read files directly from it's hard disk. This isn't how client server architecture is intended to work. -
How to use the kxml parser?
I am getting problem in using the kxml parser.Actually my application is showing the java.lang.NoClassDefFoundError: org/kxml/parser/XmlParser error.
Can you tell me how to use the kxml parser with our j2me application or what are the steps for this?
Whether we have to use the kxml.zip or some other JAR file for this?
Again whether we have to set any classpath for this?I was getting same error using kxml parser. The reason is losing interface in which constants are declared.
You need to correct code of kxml a bit.
In every place where constant from XmlPullParser interface is referenced only by its name (without reference to its class XmlPullParser) you need to change for use full name. it means changes like:
START_DOCUMENT to XmlPullParser.START_DOCUMENT
Everywhere.
That's all!
Maybe you are looking for
-
How to integrate custom / application generated data to the endeca search results
Hi, I am relatively new to the ATG development. And I have a requirement of integrating application generated (read records from a Database) records to the returned results from endeca. As summary, What I need is, to display the few DB records with t
-
How do i get the camera to be beside the keyboard in messages
how do i get the camera to be beside the keyboard in messages, when you look at all the demonstrations online it shows the camera icon being there so you can add a photo to the message, but on my iphone 4 i don't have that icon.
-
I have just activated my Micro Sim (Australia) and am trying to Sync to get started. However, the phone wont sync and will only let me use it for emergency calls. There is only one small bar that is registering for service, but my Mobile service prov
-
Can I buy Elements 12 from Adobe? their website only shows upgrade to Elements 13. Photoshop Elements
-
Summing up key figure in Cube - data load from ODS
Hello Gurus, I am doing a data load from ODS to cube. The records in ODS are at line-item level, and all needs to be summed up at header level. There is only one key-figure. ODS has header and line-item fields. I am loading only header field data ( a