Need help using count over function
I have the following query
Select student_id, OM, TM, TP, count(rownum) over (order by OM desc) PS from
(select
er.student_id, sum(er.obtained_marks) OM, sum(ds.max_marks) TM,
to_char(sum(er.obtained_marks)/sum(ds.max_marks)*100,'990.00') TP
from
tbl_exam_results er, tbl_date_sheet ds
where
ds.date_sheet_id = er.date_sheet_id and ds.class_id = 77 and ds.exam_id = 3 and ds.session_id = 1 group by er.student_id
results in
<div style="width: 889px"><div class="fielddata"><div>
<div>STUDENT_ID OM TM TP PS
1825 291 300 97.00 1
3717 290 300 96.67 2
2122 289 300 96.33 3
3396 287 300 95.67{color:#ff6600} *5 <--*{color}
4554 287 300 95.67{color:#ff6600} *5 <--*{color}
1847 281 300 93.67 6
1789 279 300 93.00 7
5254 277 300 92.33 8
1836 258 300 86.00 9
4867 250 260 96.15 10
1786 249 300 83.00 11
4659 245 300 81.67 12
1835 241 300 80.33 *{color:#ff6600}15 <--{color}*
1172 241 270 89.26*{color:#ff6600} 15 <--{color}*
3696 241 300 80.33 *{color:#ff6600}15 <--{color}*
3865 234 300 78.00 16
5912 215 300 71.67 17
5913 204 300 68.00 *{color:#ff6600}19 <--{color}*
3591 204 300 68.00 *{color:#ff6600}19 <--{color}*
1830 184 250 73.60 20
</div>
</div>
</div>
</div>
<div style="width: 889px"><div class="fielddata"><div>
But I want as following
<div>STUDENT_ID OM TM TP PS
1825 291 300 97.00 1
3717 290 300 96.67 2
2122 289 300 96.33 3
3396 287 300 95.67 *{color:#ff6600}4 <={color}*
4554 287 300 95.67 *{color:#ff6600}4 <={color}*
1847 281 300 93.67 {color:#ff6600}5 the following entry{color}
1789 279 300 93.00 6
5254 277 300 92.33 7
1836 258 300 86.00 8
4867 250 260 96.15 9
1786 249 300 83.00 10
4659 245 300 81.67 11
1835 241 300 80.33 {color:#ff6600}*12 <=*{color}
1172 241 270 89.26{color:#ff6600} *12 <=*{color}
3696 241 300 80.33 {color:#ff6600}*12 <=*{color}
3865 234 300 78.00{color:#ff6600} 13 the following entry{color}
5912 215 300 71.67 14
5913 204 300 68.00 *{color:#ff6600}15<={color}*
3591 204 300 68.00 *{color:#ff6600}15 <={color}*
1830 184 250 73.60 {color:#ff6600}16{color} {color:#ff6600}the following entry{color}
</div>
Thanks in advance for any help
</div>
</div>
</div>
<div style="width: 889px"></div>
Edited by: sabir786 on Jan 14, 2009 4:13 AM
Edited by: sabir786 on Jan 14, 2009 4:17 AM
Since I do not understand at all what you are trying to do, I cannot correct your query, but I can explain the results.
The analytic function is doing a running count of the number of records that have been outout so far. With no duplicates, this is somewhat clearer.
SQL> WITH t AS (SELECT 1 om FROM dual UNION ALL
2 SELECT 2 FROM dual UNION ALL
3 SELECT 3 FROM dual UNION ALL
4 SELECT 4 FROM dual UNION ALL
5 SELECT 5 FROM dual)
6 SELECT om, COUNT(rownum) OVER (ORDER BY om) ps
7 FROM t;
OM PS
1 1
2 2
3 3
4 4
5 5However, when you have duplicates, both duplicate values get the running count from the last of the duplicates (i.e. the highest running count). Here, I have duplicated 4 and see what I get:
SQL> WITH t AS (SELECT 1 om FROM dual UNION ALL
2 SELECT 2 FROM dual UNION ALL
3 SELECT 3 FROM dual UNION ALL
4 SELECT 4 FROM dual UNION ALL
5 SELECT 4 FROM dual UNION ALL
6 SELECT 5 FROM dual)
7 SELECT om, COUNT(rownum) OVER (ORDER BY om) ps
8 FROM t;
OM PS
1 1
2 2
3 3
4 5
4 5
5 6The "second" 4 record had a running count of 5 (i.e. it was the fifth record output), so both 4's get the same count. Changing the order by to descending shows the same effect, it just changes the running count:
SQL> WITH t AS (SELECT 1 om FROM dual UNION ALL
2 SELECT 2 FROM dual UNION ALL
3 SELECT 3 FROM dual UNION ALL
4 SELECT 4 FROM dual UNION ALL
5 SELECT 4 FROM dual UNION ALL
6 SELECT 5 FROM dual)
7 SELECT om, COUNT(rownum) OVER (ORDER BY om DESC) ps
8 FROM t;
OM PS
5 1
4 3
4 3
3 4
2 5
1 6John
Similar Messages
-
Need help using the "skatter" function with brushes.
I'm using Photoshop 7 right now. I want to use the scatter function with one of the standard brushes to make a star trail, but the problem is that the stars are too thick, there's too many of them. How do I tell it to draw less instances of the brush when I'm in scatter mode? So that it's only dropping 5 at a time or so?
I have a control bar for "Master Diameter" but I can't find anything that says "spacing."
-
Need help using basic interger function
I made a basic program to calculate the arrival of a trail, but the problem
is that when i get the result of sum6 it comes out as 13.833333333333333.
I just want to remove all the numbers after 13 for the printout answer?!?!!?!
I know i have to use the "int" function to do this, but where & what do i put
in my code to do that?
thanks!!!!
// DECLARE VARIABLES/DATA DICTIONARY
double num1,num2, num3, num4 ; // Given numbers
double sum1,sum2, sum3, sum4, sum5, sum6, sum7, sum8 ; // Intermediate, sum of num1, num2, and num3
// READ IN GIVENS
System.out.println ("Please enter hour value of start time: ");
num1 = ITI1120.readDouble( );
System.out.println ("Please enter minute value of start time: ");
num2 = ITI1120.readDouble( );
System.out.println ("Please enter the speed of train (in km per hour) : ");
num3 = ITI1120.readDouble( );
System.out.println ("Please enter travel distance (in km) : ");
num4 = ITI1120.readDouble( );
// BODY OF ALGORITHM
sum1 = num1 * 60;
sum2 = sum1 + num2;
sum3 = num3 / 60;
sum4 = num4 / sum3;
sum5 = sum2 + sum4;
sum6 = sum5 / 60;
sum7 = sum6 * 60;
// PRINT OUT RESULTS
System.out.println("The hour value of the arrival time is: " + sum6);Which is easier to debug, your code with the generic variable names or this code:
System.out.println ("Please enter hour value of start time: ");
startHour = ITI1120.readDouble( );
System.out.println ("Please enter minute value of start time: ");
startMinutes = ITI1120.readDouble( );
System.out.println ("Please enter the speed of train (in km per hour) : ");
velocityKmPerHr = ITI1120.readDouble( );
System.out.println ("Please enter travel distance (in km) : ");
travelKm = ITI1120.readDouble( );
startMinutesFromHours = startHour * MINUTES_PER_HOUR;
totalMinutes = startMinutesFromHours + startMinutes;
velocityKmPerMin = velocityKmPerHr / MINUTES_PER_HOUR;
travelTimeMinutes = travelKm / velocityKmPerMin;
arrivalTimeTotalMinutes = totalMinutes + travelTimeMinutes;
arrivalTimeHours = (int)(arrivalTimeTotalMinutes / MINUTES_PER_HOUR);
noIdeaWhyYoureCalculatingThis = arrivalTimeHours * MINUTES_PER_HOUR;? -
I'm able to get the x axis information by setting arg1 to TYPE=Numeric, DATA TYPE=Signed 32-bit Integer, PASS=Pointer to Value. I wired a zero to the input.
When I setup arg2 the same, LabView crashes.???
This is the first time I've attempted to access a dll, and I'm not sure I'm on track with the operation and I appreciate any help with this matter.Hi,
What you are doing now is:
BOOL GetCursorPos(
LPPOINT lpX // cursor's X
LPPOINT lpY // cursor's Y
This is not correct! The Api pop only one parameter from stack, and returns
to the second. The second parameter should be the return andress (set
automatically), but in your case it's a pointer to lpY! So LV crashes!
This is the prototype of GetCursorPos:
BOOL GetCursorPos(
LPPOINT lpPoint // cursor position
Wire a cluster to the first parameter (set the dll to "adapt to type"). the
cluster should have two U32's in it.
Regards,
Wiebe.
"_K_" wrote in message
news:[email protected]..
> I'm able to get the x axis information by setting arg1 to
> TYPE=Numeric, DATA TYPE=Signed 32-b
it Integer, PASS=Pointer to Value.
> I wired a zero to the input.
> When I setup arg2 the same, LabView crashes.???
> This is the first time I've attempted to access a dll, and I'm not
> sure I'm on track with the operation and I appreciate any help with
> this matter. -
Can I use Count, Max function in PLSQL BLOCK.
Can U help me to use count, max function in PLSQL BLOCK.
Because it is giving me error "It is a SQL function"SELECT COUNT(*)
INTO l_variable
FROM dual;
Will work inside PL/SQL -
I need helping using iAds in my application.
I need helping using iAds in my application. I currently am not using any storyboards. I am using Sprite builder for my UI.
I attatched an image ot show all the different file name I have.
Everyone is being used & they all work fully.
The "iAdViewController.h & .m" files are just example codes I looked up and was messing with so that my iAd can work.I wouldn't even be able to use the Mathscript node in an executable?
What I am trying to do is make a user configurable data stream.
They tell me how many bytes are in the stream and what parameters they
want to be put in to it. Currently I have to make vi's that are
called dynamicaly to make the parameters. Then recompile
the code and send it to them. This is somewhat of how the config
file is set up so I know how to make the data.
Data_Type foo
Bytes 30
parameter_name
function
byte# format
sync
foo_sync
29 int
time
foo_time
1,2,3,4 double
If I can't use MathScript to allow the user to make there own functions
is there another way that I might be able to do this so I do not have
to recompile the code atleast? Were I might just be able to make
the new function and send that to them.
Any Idea would be great. -
Need help using TD1Hdl in C++
So I've generated a .dll to use in VC++. After almost 3 full days of searching forums and messing with my code I really need to get something done. The variables I'm trying to use are declared as follows:
typedef struct {
long dimSize;
LStrHandle elt[1];
} TD1;
typedef TD1 **TD1Hdl;
The function I need to call is:
void __cdecl getFileList(TD1Hdl *SpecResults);
According to LabVIEW SpecResults is an output variable that I should be able to use. It is an array of file names retrieved from a database.
I've gotten my code to compile many different ways but no matter what I do I can't get to dimSize or elt.
Here's the closest I've gotten:
int main(int argc, char *argv[])
TD1 *tdptr = new TD1;//(TD1 *)malloc(sizeof(long) + sizeof(LStrHandle));
TD1Hdl tdhdl = &tdptr;
SetupWO();
getFileList(&tdhdl);
return 0;
SetupWO() starts the main vi. getFileList() is the subvi that i want to get the array from.
Debugging with watches shows nothing in tdptr->dimSize or tdptr->elt[0].
Any help you can provide is greatly appreciated. Thanks in advance.Hi Drew!
First of all thanks for getting back to me. After almost a full week of debugging this, I think I've finally found a way to access what I need to. I've separated the code into classes now so it looks a little different but I'll post the important stuff below.
class wrapper
public:
void run();
private:
void LStrToCStr(LStrHandle lstr, char *cStrBuff, long buffLen);
TD1 tdptr;
TD1Hdl tdhdl;
void wrapper::run()
tdhdl = NULL;
SetupWO();
getFileList(&tdhdl);
tdptr.dimSize = (*tdhdl)->dimSize;
for(int i = 0; i < tdptr.dimSize; i++)
tdptr.elt[i] = (*tdhdl)->elt[i];
char atpString[256];
LStrToCStr(tdptr.elt[i], atpString, 256);
printf(atpString);
printf("\n");
void wrapper::LStrToCStr(LStrHandle lstr, char* cStrBuff, long buffLen)
int32 len = LHStrLen(lstr);
if(len >= buffLen)
len = buffLen - 1;
memcpy(cStrBuff, LHStrBuf(lstr), len);
cStrBuff[len] = 0;
This seems to be working. I figured it out probably half an hour before I went home on Friday so I haven't had a whole lot of time to mess around with it yet. The only problem I'm having is that the list I want should have 6 elements in it, but I'm only getting the first 2 when I go through the for loop before it errors. I'm sure this must be because the array was declared: LStrHandle elt[1];
I'm thinking I need to use the NumericArrayResize() function? I haven't looked into it much yet, but I plan on checking it out today. However in the mean time if you can provide any more advice that would be great!
Thanks again! -
How to connect an apple tv to an enterprise network with a username and a password?
I need to use it over my university's wifi. theres no option to enter username and password. how to connect the apple tv to such enterprise network?Contact the University's IT dept, they may be able to set something up on the network to allow the ATV to connect without the need for a user name/password.
-
How to use to use rank over() function in block coding
Hi,
I am having problem with using rank () over function in block coding. I can't use it in declaration section with select statement.
How to use in executable section of pl sql ?
--Sujanthanks
-
Re: Beginner needs help using a array of class objects, and quick
Dear Cynthiaw,
I just read your Beginner needs help using a array of class objects, and quick of Dec 7, 2006 9:25 PM . I really like your nice example.
I also want to put a question on the forum and display the source code of my classe in a pretty way as you did : with colors, indentation, ... But how ? In html, I assume. How did you generate the html code of your three classes ? By help of your IDE ? NetBeans ? References ?
I already posted my question with six source code classes ... in text mode --> Awful : See "Polymorphism did you say ?"
Is there a way to discard and replace a post (with html source code) in the Sun forum ?
Thanks for your help.
Chavadachavada wrote:
Dear Cynthiaw,
I just read your Beginner needs help using a array of class objects, and quick of Dec 7, 2006 9:25 PM . I really like your nice example.You think she's still around almost a year later?
I also want to put a question on the forum and display the source code of my classe in a pretty way as you did : with colors, indentation, ... But how ?Just use [code] and [/code] around it, or use the CODE button
[code]
public class Foo() {
* This is the bar method
public void bar() {
// do stuff
}[/code] -
i need help using the icloud it is not making any since to me can some one call me and help me with it please don't try to help me through email i need to talk and listen i don't understand instruction by reading.
<Phone Number Edited by Host>You aren't addressing anyone from Apple here. This is a user forum.
You might want to call a neaby Apple store to see if they have a free class you could attend. -
Need help using dbms_scheduler to submit an immediate job on the database
Hi. I need help using dbms_scheduler to submit an immediate job on the database. Essentially I want to issue a one-time call to an Oracle Stored Procedure - this procedure will then send an email. I've never used dbms_scheduler before, but here's what I have so far.
So my Program is a stored database procedure named 'TTMS.dropperVacationConflict_Notify', but my problem is that I need to pass 3 parameter values to this job each time I run it. This is what I can't figure out. The procedure expects an 'Id' as number(5), begin_dt as a date, and end_dt as a date.
How do I pass these values when I run my job? Can anyone help?
begin
dbms_scheduler.create_program(program_name=> 'PROG_DROPVACCONFLICTS_NOTIFY',
program_type=> 'STORED_PROCEDURE',
program_action=> 'TTMS.dropperVacationConflict_Notify',
number_of_arguments => 3,
enabled=>true,
comments=> 'Procedure to notify PCM of a Dropper Vacation Conflict. Pass in Dropper Id, Begin_dt, and End_dt');
end;
begin
dbms_scheduler.create_schedule
(schedule_name=> 'INTERVAL_EVERY5_MINUTES',
start_date=> trunc(sysdate)+18/24,
repeat_interval => 'freq=MINUTELY;interval=5',
end_date => null
comments=> 'Runtime: Every day all 5 minutes, forever'
end;
begin
dbms_scheduler.create_job
(job_name => 'JOB_DROPVACCONFLICTS_NOTIFY',
program_name => 'PROG_DROPVACCONFLICTS_NOTIFY',
schedule_name => 'INTERVAL_EVERY5_MINUTES',
enabled => true,
auto_drop => true,
comments => 'Job to notify PCM of Dropper Vacation Conflicts'
end;
/And I use this to execute the job as needed...
begin
dbms_scheduler.run_job('JOB_DROPVACCONFLICTS_NOTIFY',true);
end;
/Duplicate Post
Need help using dbms_scheduler to submit an immediate job on the database -
Help needed in using Facetime over cellular network on Ipad2 3G IOS6
i updated my Ipad2 3G to IOS6, as they mentioned that i will be able to use facetime over cellular network,
however everytime i try it over the network, it says i must connect through Wifi. any help!!Facetime over 3G is currently only available on the iPad 3, not the iPad 2 - from http://www.apple.com/ios/whats-new/ :
3. FaceTime video calling requires a FaceTime-enabled device for the caller and recipient and a Wi-Fi connection. FaceTime over a cellular network requires iPhone 4S, iPhone 5, or iPad (3rd generation) with cellular data capability. -
Need help with user defined function
Hello SDN,
I need some help with a user-defined function. My source message contains multiple
generic records (1000 char string), and my target message is 1 header record,
then multiple generic records. See description of source and target messages below:
Source:
GenericRecordTable 1..unbounded
Row (1000 char string)
Target:
Field1 (char5)
Field2 (char5)
Field3 (char5)
IT_Data
GenericRecordTable 1..unbounded
Row (1000 char string)
Basically, what I need to do in my user defined funtion is to map the first record
in my source record to the 3 header fields, then map all of the rest of the records
(starting from line 2) into the GenericRecordTable.
Can someone please help me with the code for the user defined function(s) for this
mapping?
Thank you.hi,
Activities
1. To create a new user-defined function, in the data-flow editor, choose Create New Function (This
graphic is explained in the accompanying text), which is located on the lower left-hand side of the
screen. In the menu, choose Simple Function or Advanced Function.
2. In the window that appears, specify the attributes of the new function:
Name
Technical name of the function. The name is displayed in the function chooser and on the data-flow
object.
Description
Description of how the function is used.
Cache
Function type (see above)
Argument Count
In this table, you specify the number of input values the function can process, and name them. All
functions are of type String.
3. In the window that appears, you can create Java source code:
a. You can import Java packages to your methods from the Imports input field, by specifying them
separated by a comma or semi-colon:
You do not need to import the packages java.lang., java.util., java.io., and java.lang.reflect. since
all message mappings require these packages and therefore import them. You should be able to
access standard JDK and J2EE packages of the SAP Web Application Server by simply specifying the
package under Import. In other words, you do not have to import it as an archive into the Integration
Repository. You can also access classes of the SAP XML Toolkit, the SAP Java Connector, and the
SAP Logging Service (see also: Runtime Environment (Java-Mappings)).
In addition to the standard packages, you can also specify Java packages that you have imported as
archives and that are located in the same, or in an underlying software component version as the
message mapping.
b. Create your Java source text in the editor window or copy source text from another editor.
4. Confirm with Save and Close.
5. User-defined functions are limited to the message mapping in which you created the function. To
save the new function, save the message mapping.
6. To test the function, use the test environment.
The new function is now visible in the User-Defined function category. When you select this category,
a corresponding button is displayed in the function chooser pushbutton bar. To edit, delete, or add the
function to the data-flow editor, choose the arrow next to the button and select from the list box
displayed.
http://help.sap.com/saphelp_nw04/helpdata/en/d9/718e40496f6f1de10000000a1550b0/content.htm
http://java.sun.com/j2se/1.5.0/docs/api/
/people/krishna.moorthyp/blog/2006/07/29/documentation-html-editor-in-xi
/people/sap.user72/blog/2006/02/06/xi-mapping-tool-exports
http://help.sap.com/saphelp_nw04/helpdata/en/43/c4cdfc334824478090739c04c4a249/content.htm
UDF -
http://help.sap.com/saphelp_nw04/helpdata/en/22/e127f28b572243b4324879c6bf05a0/content.htm
Regards -
Need Help in Replacement of Function Modules
Hello all,
I am working on Upgrade project from ECC 5.0 to ECC 6.0. I am facing problems for Replacement of two Obsolete Function Modules. Please give me a solution. FM's are as follows.
1) SET_AUTHORITY : This FM is obsolete in ECC 6.0 and there is not alternative FM present in help.sap.com or any other web portal.
2) WS_QUERY : Here as per my knowledge we use class CL_GUI_FRONTEND_SERVICES and methods FILE_EXIST or DIRECTORY_EXIST as per the parameters in old FM. For parameter 'FS' we use 'FILE_EXIST' and 'DS' we use 'DIRECTORY EXIST'.
But in our program prev. FM has parameter 'OS' i.e. Operating System.
But there is not method called 'OS EXIST' or similar. Please suggest suitable method.
Thanking you all in anticipation.
Best Regards,
HarishHi Harish,
I too could not find any replacement for SET_AUTHORITY
Obsolete Modules can be used in newer versions, but it is not supported by SAP in case of any technical issues.If you still need a replacement, you can replace it by the source code in the FM SET_AUTHORITY itself and modify according to your needs.
Below is the source code of FM SET_AUTHORITY, so you can modify it according to your requirement.
DATA: l_actvt TYPE tact-actvt,
l_hier TYPE STANDARD TABLE OF sethier WITH HEADER LINE.
CASE action.
WHEN 'A '.
l_actvt = activity-add.
WHEN 'C '.
l_actvt = activity-modify.
WHEN 'D '.
l_actvt = activity-display.
WHEN 'E '.
l_actvt = activity-delete.
WHEN 'UD '.
l_actvt = activity-display.
ENDCASE.
CALL FUNCTION 'G_SET_TREE_IMPORT'
EXPORTING
no_descriptions = 'X'
no_rw_info = 'X'
setid = set
tabname = table
root_header_only = 'X'
TABLES
set_hierarchy = l_hier
EXCEPTIONS
OTHERS = 0.
READ TABLE l_hier INDEX 1.
IF sy-subrc <> 0.
CLEAR l_hier.
l_hier-shortname = set.
ENDIF.
CALL FUNCTION 'G_SET_AUTHORITY_CHECK'
EXPORTING
actvt = l_actvt
authgr = l_hier-authgr
EXCEPTIONS
OTHERS = 1.
IF sy-subrc <> 0.
CASE action.
WHEN 'A '.
MESSAGE e827 WITH l_hier-shortname RAISING no_authority.
WHEN 'C '.
MESSAGE e828 WITH l_hier-shortname RAISING no_authority.
WHEN 'D '.
MESSAGE e829 WITH l_hier-shortname RAISING no_authority.
WHEN 'E '.
MESSAGE e830 WITH l_hier-shortname RAISING no_authority.
WHEN 'UD '.
MESSAGE e831 WITH l_hier-shortname RAISING no_authority.
ENDCASE.
ENDIF.
If you need help in replacing in the above source code, please post your code here so that I can help you in modifying accordingly.
Regards,
Vasuki
Maybe you are looking for
-
How to read mutiple texts using read text
Hi friends, iam facing a problem. iam using READ_TEXT function module to read the text in va01 for line item. name = w_test i always have same ie : vbeln & posnr 1000020012000010 vbeln = 1000020012 posnr = 000010 CALL FUNCTION 'READ_TEXT' EXP
-
Using express to stream stereo problem
Hi, I have a P.C with a DLINK wireless router. Using the discussion forums ive managed to get the express set up as a client and can finally stream music. However, everytime I turn the computer off and come back next time I have to go into the Admin
-
Travel Management functions interview question and answers
Hi Guys, I wanted to know Travel Management functions interview question and answers , it is most urgent for me. Your detail response will be highly appreciated. Thanks Sam.
-
What is AQ Enqueue/Dequeue
Hi , Can anybody explain me the concept of AQ Enqueue/Dequeue I google and read the document but no get clear picture Thanks in Advance
-
User Defined Field with Link Type
Hi, I am trying to create a user defined field to allow users to attach word documents to Item Master Data. I have successfully created a User Defined Field under master data with Type: Data, Structure: Link. It appears in the Item Master Data as I w